From 654d4e51fc7b677ed45ddc0875d320804085f6c6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 29 Jul 2016 09:05:12 +0200 Subject: [PATCH] Fix regression in resizing JPEG images with Imagick (#5376) Conflicts: program/lib/Roundcube/rcube_image.php --- CHANGELOG | 1 + program/lib/Roundcube/rcube_image.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fd453f9493a..8e6966218f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ CHANGELOG Roundcube Webmail =========================== - Enigma: Add possibility to configure gpg-agent binary location (enigma_pgp_agent) +- Fix regression in resizing JPEG images with Imagick (#5376) RELEASE 1.2.1 ------------- diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php index 42640f448a6..3f1e9758f08 100644 --- a/program/lib/Roundcube/rcube_image.php +++ b/program/lib/Roundcube/rcube_image.php @@ -166,10 +166,16 @@ public function resize($size, $filename = null, $browser_compat = false) else { try { $image = new Imagick($this->image_file); - - $image->setImageBackgroundColor('white'); - $image->setImageAlphaChannel(11); - $image->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN); + + try { + // it throws exception on formats not supporting these features + $image->setImageBackgroundColor('white'); + $image->setImageAlphaChannel(11); + $image->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN); + } + catch (Exception $e) { + // ignore errors + } $image->setImageColorspace(Imagick::COLORSPACE_SRGB); $image->setImageCompressionQuality(75);