symfonyliipimaginebundlephp-imagine

png_compression_level option should be an integer from 0 to 9


I am using Symfony 2.3.* and I got this error in my app/logs/dev.log when I'm using LiipImagineBundle.

request.CRITICAL: Uncaught PHP Exception Imagine\Exception\InvalidArgumentException: "png_compression_level option should be an integer from 0 to 9" at /vendor/imagine/imagine/lib/Imagine/Gd/Image.php line 535 {"exception":"[object] (Imagine\\Exception\\InvalidArgumentException: png_compression_level option should be an integer from 0 to 9 at /vendor/imagine/imagine/lib/Imagine/Gd/Image.php:535)"} []

Any solution ? Thanks

And here is my config

liip_imagine:
    resolvers:
       default:
          web_path: ~
    filter_sets:
        cache: ~
        standard:
            quality: 200
            filters:
                thumbnail: { size: [400, 300], mode: outbound }

Solution

  • I think is related to the quality setting.

    In the base Imagine bundle it has..

    // Preserve BC until version 1.0
        if (isset($options['quality']) 
            && !isset($options['png_compression_level'])) {
            $options['png_compression_level'] = 
                round((100 - $options['quality']) * 9 / 100);
        }
    
        // ...
    
        if ($format === 'png') {
            if (isset($options['png_compression_level'])) {
                if ($options['png_compression_level'] < 0 
                    || $options['png_compression_level'] > 9) {
                    throw new InvalidArgumentException(
                        'png_compression_level option should be an integer from 0 to 9'
                    );
                }
                $args[] = $options['png_compression_level'];
            } else {
                $args[] = -1; // use default level
            }
    
            // ...
        }
    

    What are your filter settings?