#3 OptiPNG doesn't work with libpng 1.5


This patch makes OptiPNG build (and work) with libpng 1.5.

There is a slight runtime misbehavior which I believe is caused by a bug in libpng rather than my patch:

[arklinux@matterhorn tmp]$ optipng -zc1-9 -zm1-9 -zs0-3 -f0-5 test.png
OptiPNG 0.6.4: Advanced PNG optimizer.
Copyright (C) 2001-2010 Cosmin Truta.

** Processing: test.png
Warning: Interlace handling should be turned on when using png_read_image
926x902 pixels, 4x8 bits/pixel, RGB+alpha
Recoverable errors found in input. Rerun OptiPNG with -fix enabled.
Error: Previous error(s) not fixed

Specifying -fix makes OptiPNG work (even though it shouldn't be necessary, the file is ok).

Unless I'm overlooking something, the warning is erroneously generated by libpng for non-interlaced PNG files - the warning is generated by png_read_image() if(!(png_ptr->transformations & PNG_INTERLACE)), but png_set_interlace_handling does png_ptr->transformations |= PNG_INTERLACE only if png_ptr->interlaced is set.


  • Cosmin Truta
    Cosmin Truta

    Thank you, Bernhard. I actually solves the build issue by removing PNG_EXPORT completely. The libpng maintainer told me some time ago that PNG_EXPORT isn't supposed to be used outside libpng.

  • Cosmin Truta
    Cosmin Truta

    • status: open --> pending-rejected
  • This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

    • status: pending-rejected --> closed-rejected