automatic pixel format for png export makes the wrong choice if the image has only gray pixels
GIMP version: 2.10.18
Note: bug reporters are expected to have verified the bug still exists either in the last stable version of GIMP or on updated development code (master branch).
Operating System: Linux
Package: archlinux (gimp 2.10.18-4)
Description of the bug
If the image contains only greyscale pixels, exporting to PNG with GIMP produces a file which is considered invalid by imagemagick:
~ $ magick test.png /dev/null
magick: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `/dev/null' @ warning/png.c/MagickPNGWarningHandler/1748.
Reproduction
Is the bug reproducible? Always.
Reproduction steps:
- Open GIMP on a brand new profile (full defaults)
- File → New, OK
- Select paintbrush tool and draw something (it will be in black on white)
- File → Export…, choose the filename, press Export
- The Export image as PNG dialog appears, press Export
You have an image that imagemagick complains is invalid (see above).
…
Expected result:
The exported PNG should not raise errors or warnings when feeding it to imagemagick.
Actual result:
Imagemagick complains that RGB color space is not permitted on grayscale PNG
Additional information
This never happens if there is any color which is not a gray within the image, for example if I add some red before exporting.
It is possible to fix this by selecting "8pbc GRAY" manually as the pixel format in the PNG export dialog in this case.
There is a discussion at imagemagick: https://github.com/ImageMagick/ImageMagick/issues/884 Nothing is "fixable" on magick's side - it is indeed an inconsistency, and as such it is reported in a warning.
Here is an example image produced using the reproduction steps: