php-imagine / Imagine

PHP Object Oriented image manipulation library
https://imagine.readthedocs.io
Other
4.42k stars 529 forks source link

Unable to work with pecl 3.4.4 and ImageMagick 6 #715

Closed samdark closed 5 years ago

samdark commented 5 years ago

Issue description

\Imagick::setImageOpacity() was deprecated in PECL extension version 3.4.4 and \Imagick::setImageAlpha() is not there before ImageMagick 7. In this case it fails with "Function Imagick::setimageopacity() is deprecated":

if (version_compare('6.3.1', $this->getVersion($imagick)) < 0) { // <-- using 6.7.7, passes
    // setImageOpacity was replaced with setImageAlpha in php-imagick v3.4.3
    if (method_exists($imagick, 'setImageAlpha')) { // <-- does not exist before 7.x.x
        $imagick->setImageAlpha($pixel->getColorValue(\Imagick::COLOR_ALPHA));
    } else {
        $imagick->setImageOpacity($pixel->getColorValue(\Imagick::COLOR_ALPHA));
        // ^ throws deprecation error with PECL 3.4.4
    }
}

What version of Imagine are you using?

1.2.1-dev

What's the PHP version you are using?

Any.

What's the imaging library you are using [gd/imagick/gmagick/any]?

What's the imaging library configuration

Does not matter.

Minimal PHP code to reproduce the error:

$imagine = new \Imagine\Imagick\Imagine();
$color = (new RGB())->color('FFF', 10);
$image = $imagine->create(new Box(100, 100), $color);
samdark commented 5 years ago

https://github.com/Imagick/imagick/issues/288

Danack commented 5 years ago

Fyi:

i) there were other methods that were deprecated also: https://pecl.php.net/package-changelog.php?package=imagick

ii) It is planned that this is the last version (other than security fixes) of Imagick that will support ImageMagick 6. Yeah I'm aware that this is going to be mildly annoying for some users.