libpng-1.6.x rejects the sRGB profile in logo:

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

libpng-1.6.x rejects the sRGB profile in logo:

Post by glennrp »

Libpng-1.6.x does more checking of ICC profiles and in particular
rejects some "sRGB" profiles that were previously acceptable to
ImageMagick. The profile embedded in "logo:" is among them.

glenn.rp> q16identify -list format | grep PNG
  • PNG* rw- Portable Network Graphics (libpng 1.6.2beta02)
    See http://www.libpng.org/ for details about the PNG format.
    PNG00* rw- PNG inheriting bit-depth and color-type from original
    PNG24* rw- opaque or binary transparent 24-bit RGB (zlib 1.2.7.1)
    PNG32* rw- opaque or transparent 32-bit RGBA
    PNG48* rw- opaque or binary transparent 48-bit RGB
    PNG64* rw- opaque or transparent 64-bit RGBA
    PNG8* rw- 8-bit indexed with optional binary transparency
glenn.rp> q16convert logo: logo.png
q16convert: known incorrect sRGB profile `logo.png' @ error/png.c/MagickPNGErrorHandler/1761.
glenn.rp>

libpng-1.6.1/png.c says
  • if (png_sRGB_checks.is_broken)
    {
    /* These profiles are known to have bad data that may cause
    * problems if they are used, therefore attempt to
    * discourage their use, skip the 'have_md5' warning below,
    * which is made irrelevant by this error.
    */
    png_chunk_report(png_ptr, "known incorrect sRGB profile",
    PNG_CHUNK_ERROR);
    }

    /* Warn that this being done; this isn't even an error since
    * the profile is perfectly valid, but it would be nice if
    * people used the up-to-date ones.
    */

I'm getting more than just a warning. "convert" doesn't write an
output PNG. I got the same behavior with ImageMagick built with
libpng-1.6.1 and running with the 1.6.2beta02 shared library.

I have checked in a simple fix (adding a call to png_set_benign_errors())
that causes IM to issue a warning instead of an error. SVN r 11879.

With the fix I get
glenn.rp> q16convert logo: logo.png
q16convert: known incorrect sRGB profile `logo.png' @ warning/png.c/MagickPNGWarningHandler/1787.
q16convert: profile 'sRGB': 0h: inconsistent rendering intents `logo.png' @ warning/png.c/MagickPNGWarningHandler/1787.
glenn.rp>

and logo.png is written without an iCCP chunk.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: libpng-1.6.x rejects the sRGB profile in logo:

Post by magick »

Thanks Glenn, we'll try and fix the sRGB profile, that should ameliorate the problem.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: libpng-1.6.x rejects the sRGB profile in logo:

Post by glennrp »

magick wrote:Thanks Glenn, we'll try and fix the sRGB profile, that should ameliorate the problem.
We'll want to replace it with one that has a "free" license (the one currently embedded in "logo:" has
a license that prevents modifying it so is non-free). I recommend the sRGB profile supplied with Argyllcms;
it is public domain and appears to be a good one.
Post Reply