Hendra Huang
Hendra Huang

Reputation: 528

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 }

Upvotes: 1

Views: 1187

Answers (2)

borN_free
borN_free

Reputation: 1482

If you are using SonataMediaBundle, check that quality is not more than 100.

Upvotes: 6

qooplmao
qooplmao

Reputation: 17759

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?

Upvotes: 1

Related Questions