IM gives profile error when doing composite
Posted: 2018-01-29T21:11:59-07:00
ImageMagick 7.0.7-22 Q16 HDRI x64 on Windows 10 64-bit
IM is giving me the following error in my Windows batch script:
magick: color profile operates on another colorspace `icc' @ error/profile.c/ProfileImage/1018.
when I do the following sequence of processing on a 16-bit grayscale TIFF image which has an embedded Gray Gamma 2.2 profile (this is a simplified version of the actual code):
Here's explanation of the steps, line by line:
// save the embedded profile to local disk
// read in the image to memory
// convert to linear gray space using a local profile
// resize the image
// create sharpened image in gamma 3 ("background" for the upcoming composite)
// create sharpened image ("source" for the upcoming composite)
// delete the original image at index 0
// create blend mask based on the "source" image
// blend background and source using mask (composite)
// convert back to original non-linear gray space using the previously saved profile
// set new resolution in meta-data
// add a comment to meta-data
// write the image to output file
As best I can tell, IM seems to have a problem at the profile conversion step (back to the original non-linear gray space). The error message seems to suggest IM was perhaps in an incompatible color space after the composite. Is IM making some bad colorspace assumptions during the cloning and composite steps? Or am I not understanding how to use "-profile" for the conversions in and out of linear space for grayscale files?
Now here's the interesting part: I modified line two above as follows:
and this eliminates the profile error message. My guess is that the addition of "-type Grayscale" somehow removes the confusion for IM, but I'd like some confirmation that including this is the proper way to fix the error, or if not, some guidance on the proper way to address it.
Thanks,
Dave
IM is giving me the following error in my Windows batch script:
magick: color profile operates on another colorspace `icc' @ error/profile.c/ProfileImage/1018.
when I do the following sequence of processing on a 16-bit grayscale TIFF image which has an embedded Gray Gamma 2.2 profile (this is a simplified version of the actual code):
Code: Select all
magick -quiet input.tif embedded.icc
magick -quiet input.tif
-profile Gray-elle-V2-g10.icc
-filter Cubic -distort Resize 10800
( -clone 0 -gamma 3 -define convolve:scale=100%,100 -morphology Convolve DoG: ... -gamma 0.333333 )
( -clone 0 -define convolve:scale=100%,100 -morphology Convolve DoG: ... )
-delete 0
( -clone 1 -auto-level )
-compose over -composite
-profile embedded.icc
-set density 720x720
-set comment "Created by ImageMagick"
output.tif
// save the embedded profile to local disk
// read in the image to memory
// convert to linear gray space using a local profile
// resize the image
// create sharpened image in gamma 3 ("background" for the upcoming composite)
// create sharpened image ("source" for the upcoming composite)
// delete the original image at index 0
// create blend mask based on the "source" image
// blend background and source using mask (composite)
// convert back to original non-linear gray space using the previously saved profile
// set new resolution in meta-data
// add a comment to meta-data
// write the image to output file
As best I can tell, IM seems to have a problem at the profile conversion step (back to the original non-linear gray space). The error message seems to suggest IM was perhaps in an incompatible color space after the composite. Is IM making some bad colorspace assumptions during the cloning and composite steps? Or am I not understanding how to use "-profile" for the conversions in and out of linear space for grayscale files?
Now here's the interesting part: I modified line two above as follows:
Code: Select all
magick -quiet input.tif -type Grayscale
Thanks,
Dave