Skip to content

Commit

Permalink
Use setImageAlpha instead of deprecated setImageOpacity
Browse files Browse the repository at this point in the history
This fixes a backwards compatibility issue introduced with
v3.4.3 of the php imagick extension. The method has been renamed to
setImageAlpha. See the imagick release notes for more info.

https://pecl.php.net/package-changelog.php?package=imagick&release=3.4.3

Fixes #539
  • Loading branch information
jdewit committed Mar 3, 2017
1 parent e3d9294 commit 32af6fb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Imagine/Imagick/Imagine.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public function create(BoxInterface $size, ColorInterface $color = null)
$imagick->setImageBackgroundColor($pixel);

if (version_compare('6.3.1', $this->getVersion($imagick)) < 0) {
$imagick->setImageOpacity($pixel->getColorValue(\Imagick::COLOR_ALPHA));
// setImageOpacity was replaced with setImageAlpha in php-imagick v3.4.3
if (method_exists($imagick, 'setImageAlpha')) {
$imagick->setImageAlpha($pixel->getColorValue(\Imagick::COLOR_ALPHA));
} else {
$imagick->setImageOpacity($pixel->getColorValue(\Imagick::COLOR_ALPHA));
}
}

$pixel->clear();
Expand Down

0 comments on commit 32af6fb

Please sign in to comment.