Imagemagick: Error reading grayscale png

Created on 25 Nov 2017  路  6Comments  路  Source: ImageMagick/ImageMagick

Recent versions of IM6 throw an error when reading grayscale PNG images. The problem is not present on older versions of IM. Here is an example image gray.png

> convert gray.png out.png
ERROR: convert: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `out.png' @ # warning/png.c/MagickPNGWarningHandler/1665.

The image is recognized as Type: GrayscaleAlpha but still set to Colorspace: sRGB.

identify -verbose gray.png | head -n10
Image: gray.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 480x480+0+0
  Units: Undefined
  Type: GrayscaleAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit

In older versions of IM this image gets (correctly) recongized as Type: Grayscale.

Most helpful comment

Try this:

convert gray.png -strip out.png

All 6 comments

Try this:

convert gray.png -strip out.png

That works for the toy example, but real problem actually appears in my C++ bindings.

Here is yet another report of this problem. Is there some way to add a fix that does not require the user to manually add strip = TRUE to read grayscale pngs?

This works for me:

convert gray.png +profile "*" tmp.png

or

convert gray.png +profile "icc" tmp.png

@w-A-L-L-e We closed this issue because we are not raising an error. The message is a warning that grayscale images don't support RGB color profiles. But warning can be ignored. @jeroen has done this by enabling the quiet option in Magick++ (https://github.com/ropensci/magick/commit/289e997896b037517a3cb46400015e1b138555d9). You could also ignore them on the command line with -quiet. I have no idea how you need to do that with mini_magick though.

Ok so really thanks for your reply as it pointed me to look further than my initial wrong assumption why it wasn't working on our system (http://favicon.sitweb.eu). Indeed the the warning does happen but the images are still scaled by imagemagick so my remark was wrong and I deleted it to avoid confusion. Also I found a possible workaround/solution to our specific problem by using png32:image.png as filename imagemagick also converts greyscale to rgba and then all our old issues should be fixed. Really cool that imagemagick also supports conversion between png formats. Keep up the great work!

Was this page helpful?
0 / 5 - 0 ratings