GM writes color profile into grayscale images
Swiss army knife of image processing
Brought to you by:
bfriesen
GraphicsMagick 1.3.23 2015-11-07 Q16 http://www.GraphicsMagick.org/
gm convert -flatten -colorspace gray test1.png test2.png
http://ipic.su/img/img7/fs/test1.1459623330.png
http://ipic.su/img/img7/fs/test2.1459623330.png
It is ok to have a color profile in a grayscale image. I assume that the problem is that the original color profile is no longer the correct type for the image.
If your original image has a color profile, then the correct way to convert to a gray image is using a color profile for the colorspace of the grey image with the -profile option. Otherwise you are only getting default Rec.601 behavior which assumes that the input colors match Rec.601.
The PNG specification doesn't allow that (I happen to think that that is an unnecessary restriction in the PNG spec, but it is what it is). The libpng16 decoder will reject it. Earlier versions of libpng don't inspect the iCCP chunk.
I looked closely: GM makes the RGB image, and without an option '-flatten' - grayscale + alpha.
http://i.imgur.com/RemweSY.png
If PNG does not allow color profiles for grayscale images then how can PNG support greyscales which are anything but a simple gamma curve?
I wanted grayscale image and used "-colorspace gray" option, but GM makes RGB image