Page 1 of 1

-clone converts grayscale image to sRGB

Posted: 2018-01-30T16:04:21-07:00
by datro
Please see the following thread for all the details:

viewtopic.php?f=1&t=33440

Re: -clone converts grayscale image to sRGB

Posted: 2018-01-31T15:59:52-07:00
by datro
For anyone following this bug:
There have been a number of additional updates to the linked thread above which include important new information.

Re: -clone converts grayscale image to sRGB

Posted: 2018-01-31T18:17:26-07:00
by magick
We require a minimal command line to reproduce the problem before we will investigate further. These commands prove -clone does not affect the image colorspace:

Code: Select all

convert logo: logo.pgm
convert logo.pgm -clone 0 -delete 0 logo.mpc
identify -verbose logo.mpc
head logo.mpc
...
type=Grayscale
colorspace=Gray
...
What are the fewest command-line options you can come up with that illustrates the problem you are having. We will investigate further once we see what you come up with.

Re: -clone converts grayscale image to sRGB

Posted: 2018-01-31T20:15:01-07:00
by datro
OK, try this (IM 7.0.7-22 Q16 HDRI) on Windows 10:

This fails:

Code: Select all

magick input.tif -write input.icc ^
-profile Gray-elle-V2-g10.icc -distort Resize 500 ^
( -clone 0 -gamma 3 -gamma 0.33333 ) ( -clone 0 ) -delete 0  ( -clone 1 ) -compose over -composite ^
-profile input.icc output.tif
Result:

Code: Select all

magick: color profile operates on another colorspace `icc' @ error/profile.c/ProfileImage/1018.
This is as simple as I can make it. As explained in my last post of the above referenced thread, the problem is not with clone per se, but with how the resize and the first clone (with the gamma conversion) in the sequence above interact.

If you take out the resize, it works:

Code: Select all

magick input.tif -write input.icc ^
-profile Gray-elle-V2-g10.icc ^
( -clone 0 -gamma 3 -gamma 0.33333 ) ( -clone 0 ) -delete 0  ( -clone 1 ) -compose over -composite ^
-profile input.icc output.tif

Code: Select all

magick identify output.tif
output.tif TIFF 600x761 600x761+0+0 16-bit Grayscale Gray 942600B 0.000u 0:00.000
"input.tif" and "Gray-elle-V2-g10.icc" can be obtained here for testing:
https://www.dropbox.com/sh/svxba869nhqa ... lD-za?dl=0

(Edit: Fixed dropbox link)

Hope this helps.

Re: -clone converts grayscale image to sRGB

Posted: 2018-02-02T17:02:45-07:00
by fmw42
I have some further simpler tests that show it is related to adding -evaluate pow 0.5 in combination with -distort Resize, but works using -evaluate pow 2

This works in IM 7 -- no -evaluate pow 0.5

Code: Select all

magick input.tif -write input.icc \
-profile Gray-elle-V2-g10.icc -distort Resize 500 \
\( -clone 0  \) -compose over -composite \
-profile input.icc output.tif


This fails in IM 7 -- with -evaluate pow 0.5

Code: Select all

magick input.tif -write input.icc \
-profile Gray-elle-V2-g10.icc -distort Resize 500 \
\( -clone 0 -evaluate pow 0.5  \) -compose over -composite \
-profile input.icc output.tif


This works in IM 7 -- with -evaluate pow 2

Code: Select all

im7 magick input.tif -write input.icc \
-profile Gray-elle-V2-g10.icc -distort Resize 500 \
\( -clone 0 -evaluate pow 2  \) -compose over -composite \
-profile input.icc output.tif


This works in IM 6 -- with -evaluate pow 0.5

Code: Select all

convert input.tif -write input.icc \
-profile Gray-elle-V2-g10.icc -distort Resize 500 \
\( -clone 0 -evaluate pow 0.5  \) -compose over -composite \
-profile input.icc output.tif


It also works if one takes out the -distort Resize but keep the -evaluate pow 0.5

Code: Select all

magick input.tif -write input.icc \
-profile Gray-elle-V2-g10.icc \
\( -clone 0 -evaluate pow 0.5  \) -compose over -composite \
-profile input.icc output.tif

Re: -clone converts grayscale image to sRGB

Posted: 2018-02-03T09:15:48-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.