IM automatically (and correctly) converts linear RGB images to nonlinear when writing to a nonlinear sRGB format like JPEG:
Code: Select all
magick test.jpg -colorspace RGB testLinearRgb.jpg
testLinearRgb.jpg (OKAY)
Also, when a linear RGB colorspace image is in fact "grayscale" (three equal channels), it automatically (and correctly) converts from linear RGB to a nonlinear Grayscale JPEG (single channel in the file):
Code: Select all
magick test.jpg -grayscale Rec709Luminance -colorspace RGB testLinearGrayLinearRgb.jpg
magick test.jpg -grayscale Rec709Luma -colorspace RGB testNonlinearGrayLinearRgb.jpg
testNonlinearGrayLinearRgb.jpg (OKAY)
And it even automatically (and correctly) converts nonlinear Gray images to linear when writing to a linear file format like HDR:
Code: Select all
magick test.jpg -grayscale Rec709Luma testNonlinearGray.hdr # nonlinear gray to linear hdr
magick test.jpg -grayscale Rec709Luminance testLinearGray.hdr # linear gray to linear hdr
testLineargray.hdr.jpg (OKAY)
testNonlineargray.hdr.jpg (OKAY)
But it seems that IM(7.0.6) does not convert a linear Gray image to nonlinear when writing it to a jpeg file, so the result becomes darker:
Code: Select all
magick test.jpg -grayscale Rec709Luminance testLinearGray.jpg
magick test.jpg -colorspace RGB -grayscale Rec709Luminance testLinearRgbLinearGray.jpg
testLinearRgbLinearGray.jpg (too dark)
(Same problem should occur with Rec601Luminance as with Rec709Luminance since both produce a linear result.)
(The same problem might occur with at least some other nonlinear-only or even nonlinear-by-default file formats but I wanted to keep this bug report simple and see what the response might be.)
This is with IM 7.0.6-2 Q16 HDRI (x64 under Windows 7).
(Of course once the user realizes that this problem occurs just when you write a Gray colorspace linear image to a nonlinar format like JPEG, he can work around it with an explicit -colorspace sRGB for example {using a non-Gray colorspace since IM does not support conversion between linear Gray and nonlinear Gray}, but no such explicit colorspace transformation by the user is required for any of the other related examples above, where the conversion between linear and nonlinear is done by IM automatically and transparently without the user having to know the linearity/nonlinearity of the image and/or the linearity/nonlinearity of the target file format.)