Skip to content

Commit

Permalink
Set the initial imagick colorspace whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Oct 18, 2021
1 parent 57be1a5 commit 0eac9a2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Imagick/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(\Imagick $imagick, PaletteInterface $palette, Metada
{
$this->metadata = $metadata;
$this->imagick = $imagick;
if (static::getDriverInfo()->hasFeature(DriverInfo::FEATURE_COLORSPACECONVERSION)) {
if (method_exists($imagick, 'setcolorspace')) {
$this->setColorspace($palette, false);
}
$this->palette = $palette;
Expand Down Expand Up @@ -998,7 +998,7 @@ private function setColorspace(PaletteInterface $palette, $convert)
}
} catch (\ImagickException $x) {
// Old ImageMagick versions ( < 6.8.0-4) were affected by a bug, fixed in https://github.com/ImageMagick/ImageMagick6/commit/8354515c613b61bd52e025ec0f6799cbf0f1a069
if ($x->getMessage() !== 'Unable to set image alpha channel' || version_compare(Imagine::getExtensionInfo()->getImageMagickSemVerVersion(), '6.8.0') > 0) {
if ($x->getMessage() !== 'Unable to set image alpha channel' || version_compare($this->getDriverInfo()->getEngineVersion(), '6.8.0') > 0) {
throw $x;
}
}
Expand Down

0 comments on commit 0eac9a2

Please sign in to comment.