I have a 32-bit floating point TIFF image that when I try to adjust it with ImageMagick it creates a sRGB image. No matter what I've tried, I cannot adjust the image that creates a grayscale image. The odd thing is, I have other TIFF images created the same exact way from the same software, and they don't have the problem.
> identify grayImage.tif
grayImage.tif TIFF 4096x3283 4096x3283+0+0 32-bit Grayscale Gray 51.3417MiB 0.000u 0:00.000
If I run convert or magick without any adjustments, it writes a gray scale image. But if I try to adjust the levels or gamma, it writes a sRGB image:
> magick grayImage.tif -gamma 0.96 grayImageOut.tif
> identify grayImageOut.tif
grayImageOut.tif TIFF 4096x3283 4096x3283+0+0 32-bit sRGB 153.892MiB 0.000u 0:00.000
I've tried setting the color space to grayscale, but the resulting image is still RGB:
> magick grayImage.tif -gamma 0.96 -set colorspace Grayscale grayImageOut.tif
I've tried extracting the R channel, and the output is still sRGB:
> magick grayImage.tif -gamma 0.96 -channel R -separate -set colorspace Grayscale grayImageOut.tif
> identify grayImageOut.tif
grayImageOut.tif TIFF 4096x3283 4096x3283+0+0 32-bit sRGB 153.892MiB 0.000u 0:00.000
How can I work around this issue and create a grayscale image?
It works for me with IM 7.1.1.21 on Mac OSX Ventura. You need to add -type grayscale to the command as well as the defines in my comment.
magick -quiet -define quantum-format=floating-point -depth 32 grayImageTest.tif -gamma 0.96 -type grayscale x.tif
magick identify x.tif
x.tif TIFF 4096x3283 4096x3283+0+0 32-bit Grayscale Gray 51.2975MiB 0.000u 0:00.001