Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#35 invalid encoding parameters

closed-fixed
Cosmin Truta
None
5
2012-08-25
2012-05-17
John Sauter
No

When I attempt to process a large file with optipng 0.7.1 I get an error message after many hours of processing. Here is the full output:

** Processing: P1230416-P1230977.png
89633x25433 pixels, 4x8 bits/pixel, RGB+alpha
Input IDAT size = 2321059519 bytes
Input file size = 2324459581 bytes

Trying:

Selecting parameters:
zc = -1 zm = -1 zs = -1 f = -1 IDAT size = 2147483648

** INTERNAL ERROR: Invalid encoding parameters
Please submit a defect report.
http://optipng.sourceforge.net/

Discussion

  • John Sauter
    John Sauter
    2012-05-17

    program to write a large PNG file

     
    Attachments
  • John Sauter
    John Sauter
    2012-05-17

    I tried to upload the PNG file that caused the program, but it appeared to be taking forever.. Instead I have uploaded a program which writes large PNG files. The program depends on package libpng12-dev. Compile it with gcc -lpng. Run it with -s 60000 -r 5 -o bigfile.png. You will get an 8.8 GB PNG file which passes pngcheck.

    When you run optipng 0.7.1 on the resulting bigfile.png it writes out a file that fails pngcheck with a CRC error, and when optipng 0.7.1 tries to read the file it also detects an error. This isn't exactly the same symptom reported above, but it is probably related, and does not require uploading a 2.3 GB file.

    Run the program with smaller -s to get smaller images, which will result in smaller PNG files. Reducing -r will allow the images to compress better, which will also result in smaller PNG files. -h prints a usage message.

    I dedicate this program to the public domain: anyone can use it, at any time, for any purpose, without any further permission from me.

     
  • John Sauter
    John Sauter
    2012-05-18

    Running the checkerboard program with -s 30000 -r 5 produces a PNG file which exactly reproduces the symptom reported in this defect report: I ran optipng 0.7.1 with -o 7.

    ** Processing: checkerboard_30000.png
    30000x30000 pixels, 3x8 bits/pixel, RGB
    Input IDAT size = 2368205785 bytes
    Input file size = 2371674886 bytes

    Trying:

    Selecting parameters:
    zc = -1 zm = -1 zs = -1 f = -1 IDAT size = 2147483648

    ** INTERNAL ERROR: Invalid encoding parameters
    Please submit a defect report.
    http://optipng.sourceforge.net/

    The execution of this program has been terminated abnormally.

     
  • Cosmin Truta
    Cosmin Truta
    2012-07-31

    I confirm the defect. Thank you very much for the test case, and for the detailed analysis.
    This is happening because of the attempt to join all IDATs into a single one. When it passes the 2GB magic limit, it fails.
    The proper solution would be to break all IDATs into chunks of 2GB, but that requires a lot of work.
    An easier solution would be not to join IDATs at all, if the total size is known to exceed 2GB, but even that is to be analyzed carefully. For example, at -o1, the total size is not known a-priori.
    The last solution (which is not really a solution, but rather a bailout) is to issue a more useful diagnostic message and abandon the optimization altogether.
    It all depends on how I will be able to find volunteers to implement any of these fixes.

     
  • Cosmin Truta
    Cosmin Truta
    2012-07-31

    • status: open --> open-accepted
     
  • Cosmin Truta
    Cosmin Truta
    2012-08-25

    I am marking this bug as Fixed, although the "fix" consists of merely diagnosing the issue properly. I will give it more consideration if huge (2GB+) PNG images become pervasive.

    It is worth mentioning that common PNG encoders, which do not attempt to join the IDAT chunks, are unaffected by this issue.

     
  • Cosmin Truta
    Cosmin Truta
    2012-08-25

    • assigned_to: nobody --> cosmin
    • status: open-accepted --> closed-fixed