png_compression_level选项应该是0到9之间的整数

时间:2014-07-18 09:41:48

标签: symfony liipimaginebundle php-imagine

我正在使用Symfony 2.3。*,当我使用LiipImagineBundle时,我的app / logs / dev.log中出现此错误。

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)"} []

任何解决方案?感谢

这是我的配置

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

2 个答案:

答案 0 :(得分:3)

如果您使用的是SonataMediaBundle,请检查quality是否不超过100个。

答案 1 :(得分:1)

我认为与质量设置有关。

在基础Imagine捆绑中,它有..

// 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
        }

        // ...
    }

您的滤镜设置是什么?