From 7e1e73ba1d3a6364d43ac3540f94463c627e0888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sillanp=C3=A4=C3=A4?= Date: Mon, 23 Feb 2015 09:08:33 +0200 Subject: [PATCH] Improve compression of record images. --- module/Finna/src/Finna/Cover/Loader.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/module/Finna/src/Finna/Cover/Loader.php b/module/Finna/src/Finna/Cover/Loader.php index d3cfa071d23..103fc884f7a 100644 --- a/module/Finna/src/Finna/Cover/Loader.php +++ b/module/Finna/src/Finna/Cover/Loader.php @@ -315,6 +315,8 @@ protected function processImageURL($url, $cache = true) ); imagefill($imageGDResized, 0, 0, $background); + $quality = 90; + // If both dimensions are smaller than the new image, // just copy to center. Otherwise resample to fit if necessary. if ($width < $reqWidth && $height < $reqHeight) { @@ -323,7 +325,7 @@ protected function processImageURL($url, $cache = true) imagecopy( $imageGDResized, $imageGD, $imgX, $imgY, 0, 0, $width, $height ); - if (!@imagejpeg($imageGDResized, $finalFile)) { + if (!@imagejpeg($imageGDResized, $finalFile, $quality)) { return false; } } elseif ($width > $reqWidth || $height > $reqHeight) { @@ -346,11 +348,11 @@ protected function processImageURL($url, $cache = true) $newWidth, $newHeight, $width, $height ); } - if (!@imagejpeg($imageGDResized, $finalFile)) { + if (!@imagejpeg($imageGDResized, $finalFile, $quality)) { return false; } } else { - if (!@imagejpeg($imageGD, $finalFile)) { + if (!@imagejpeg($imageGD, $finalFile, $quality)) { return false; } }