\Imagick::COLOR_OPACITY 报错

bug问题 · censhine · 于 6年前 发布 · 3367 次阅读

放到linux上,访问产品页出现错误:

PHP Fatal Error – yii\base\ErrorException

Undefined class constant 'COLOR_OPACITY'

in /data/www/xxx.com/fecshop/vendor/imagine/imagine/lib/Imagine/Imagick/Imagine.php at line 80
71727374757677787980818283848586878889    {
        $width  = $size->getWidth();
        $height = $size->getHeight();
 
        $color = null !== $color ? $color : new Color('fff');
 
        try {
            $pixel = new \ImagickPixel((string) $color);
            $pixel->setColorValue(
               ** \Imagick::COLOR_OPACITY,**
                number_format(abs(round($color->getAlpha() / 100, 1)), 1)
            );
 
            $imagick = new \Imagick();
            $imagick->newImage($width, $height, $pixel);
            $imagick->setImageMatte(true);
            $imagick->setImageBackgroundColor($pixel);
 
            $pixel->clear();

确定安装好了Imagick扩展

共收到 8 条回复
Fecmall#16年前 0 个赞

您好,这个是扩展:https://github.com/avalanche123/Imagine

这里是最新的版本号:https://github.com/avalanche123/Imagine/releases

fecshop配置的是0.5.*

您升级一下试试,在根目录中打开composer.json, 可以看到require部分的配置

"require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": ">=2.0.6",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
		"yiisoft/yii2-apidoc": "~2.0.0",
        "fancyecommerce/fecshop": ">=1.2.2.4"
    },

加入这个配置 "imagine/imagine": "0.7.*",,加入后的配置为:

"require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": ">=2.0.6",
        "imagine/imagine": "0.7.*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
		"yiisoft/yii2-apidoc": "~2.0.0",
        "fancyecommerce/fecshop": ">=1.2.2.4"
    },

然后在根目录下执行 composer update 更新一下这个包,然后试试

Fecmall#26年前 0 个赞

我看了一下:

https://github.com/avalanche123/Imagine/blob/develop/lib/Imagine/Imagick/Imagine.php

这里面的内容已经和0.5版本的内容不一样,做了改动,更新下这个包应该就好了

Fecmall#36年前 0 个赞

是否解决了?如果解决,请回复一下,方便给其他人提供参考。

censhine#46年前 0 个赞

@Terry #3楼 您好,我是将 \Imagick::COLOR_OPACITY 改为 \Imagick::COLOR_ALPHA 后恢复正常~谢谢!

Fecmall#56年前 0 个赞

@censhine #4楼 升级一下这个包,应该会更好

censhine#66年前 0 个赞

@Terry #5楼 升级过程中卡死。。。我用的是PHP5.6,那个常量COLOR_OPACITY不支持了?

Fecmall#76年前 0 个赞

@censhine #6楼 我是5.4,和php7两个版本,没有出你的那个问题,我升级一下这个包

wubuyun#84年前 0 个赞

我用的是ubuntu 18 php 7.3 nginx 确定安装好了Imagick扩展 3.4.4 \Imagick::COLOR_OPACITY 报错,

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics