Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
moldawe
Posts: 8
Joined: 2019-07-23T23:32:23-07:00
Authentication code: 1152

Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by moldawe »

Hello guys!

When converting an RGB-image (which has no profile assigned) using 2 profiles, first to CMYK and then back to sRGB, the image gets inverted/negated.

convert iStock-91626310_without_Profile.tif -alpha opaque -units PixelsPerInch -density 100 -alpha off -profile "D:\VMPROGRAMS\masterdaemon\jdaemon\CoatedFOGRA39.icc" -profile "D:\VMPROGRAMS\masterdaemon\jdaemon\sRGB_IEC61966-2-1_black_scaled.icc" -set option:modulate:colorspace hsb -modulate 102,108 -filter Cosine -resize 63% -strip -quality 80 iStock-91626310_without_Profile.jpg

When I do the same with the same image but with an assigned sRGB profile, the convertion works fine.

Seems for me like a bug. In an older version 6.9.8-8 it worked fine. Any ideas?

Best regards
Viktor
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by snibgo »

If the image has no embedded profile, then the first "-profile" is assigned, and the second "-profile" converts from the first to the second.

Assignment merely sets metadata that declares what the pixel values mean.

You say the image is RGB. So your input image is actually encoded with the RGB model, and you are assigning a CMYK profile, which will invert the image (roughly speaking).

Yes, this is a bug, but I'm afraid it's your bug.
snibgo's IM pages: im.snibgo.com
moldawe
Posts: 8
Joined: 2019-07-23T23:32:23-07:00
Authentication code: 1152

Re: Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by moldawe »

Why should embedding a CMYK-profile into an RGB-image invert the colors??? Sorry, but there is no reason why embedding a CMYK-profile should invert colors.
Converting from RGB to CMYK implies losses. But though it should work. I've done this in Photoshop - works fine. Also in previous versions of ImageMagick this worked fine. But in the current version it doesn't work anymore.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by snibgo »

In ImageMagick, assigning a profile merely sets metadata that declares what the channels mean (and some other stuff, not relevant here).

Your input file has an additive Red channel, where 0 means "no red" (ie dark) and 100% means full red (ie lighter). When you declare this to be Cyan, 0 means no cyan ink (ie light) and 100% means full cyan ink (ie darker). So this reverses colours and tones.

When you have an RGB image, assigning a CMYK makes no sense, unless you want this reversal. Then converting to an sRGB profile creates reversed RGB colours, of course.

Perhaps you intended to merely assign the sRGB profile. That would make sense.
snibgo's IM pages: im.snibgo.com
moldawe
Posts: 8
Joined: 2019-07-23T23:32:23-07:00
Authentication code: 1152

Re: Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by moldawe »

OK, but why did this work in previous versions? And if this is the case then the behavior should be the same in Photoshop, right? But it isn't.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by snibgo »

When there is no embedded profile, "-profile" changes metadata and embeds the profile -- the profile is "assigned".

When there is an embedded profile, "-profile" converts pixel values to the new profile, changes metadata, removes the old profile and embeds the new profile -- the image is "converted" to the new profile.

IM allows you to assign any profile to any image.

As far as I know, IM has always worked like this.

I don't know Photoshop, sorry. Perhaps your operation silently assigns an RGB profile, then converts to the CMYK profile.
snibgo's IM pages: im.snibgo.com
cri_sen
Posts: 1
Joined: 2019-07-26T00:59:46-07:00
Authentication code: 1152

Channel statistics to rescue?

Post by cri_sen »

Hi there,

I presume that Adobe investigates the channels when no profile is embedded.
If I do an identify verbose on such images I still see in channel statistics what chanels are used (rgb, cmy, ...).
So maybe ImageMagick could try to detect the colorspace too...

Greets.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug with "convert" in version 6.9.10-56 Q16 x64 2019-07-21

Post by snibgo »

IM won't assign a profile, or convert to a new profile, unless we tell it to.

In a colour-managed workflow, we need to decide what to do with input images that don't have embedded ICC profiles. Plausible actions are:

1. For images using the RGB model, assign a particular sRGB profile.

2. For images using the CMYK model, assign a particular CMYK profile.

3. For images using any other colour model, raise an error.

Other actions might be taken, eg to account for linear-encoded images. These all depend on circumstances, and the IM user (or script writer) should decide.
snibgo's IM pages: im.snibgo.com
Post Reply