png compression error

  • Flavio Avelar Cambraia

    I get the following error when dealing with a png file:
    Line -> 39
    File -> C:\EasyPHP\www\projeto\config\wide_image\Mapper\PNG.php
    Description -> imagepng(): gd-png error: compression level must be 0 through 9.

    My script works fine with jpg and gif. I am doing this:
    $image = WideImage::load($filein);
    $back_color = $image->allocateColor(255, 0, 0);
    $resized = $image->resize($max_width, $max_height, 'inside')->resizeCanvas($max_width, $max_height, 'center', 'center', $back_color);


  • Flavio Avelar Cambraia

    Ops, I just found my error.
    I have to test the file (jpg or png) and set compression before saving.

  • Gasper Kozak

    Gasper Kozak - 2014-02-04


    PNG doesn't have quality, only compression.

    Quote from WideImage doc:

    Note: don’t be confused if you notice that the compression level parameter of imagepng() has been incorrectly named “quality” in the PHP manual. PNG format has no quality the way JPEG has it (smaller file size ~= uglier image). It’s a lossless image format, so no detail is lost (= the quality remains the same) regardless of the compression level.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks