From 3ca7ad5e9487aad182d6e3642b3aa4ca4cd97f8b Mon Sep 17 00:00:00 2001 From: Parziphal Date: Tue, 31 Dec 2013 12:01:35 -0500 Subject: [PATCH] Imagick wasn't creating JPG outputs. Added a little comment regarding animated GIFs. --- lib/Moebooru/Resizer.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Moebooru/Resizer.php b/lib/Moebooru/Resizer.php index 0827657..99e7ca3 100755 --- a/lib/Moebooru/Resizer.php +++ b/lib/Moebooru/Resizer.php @@ -22,11 +22,19 @@ abstract class Resizer if (class_exists('Imagick', false)) { $image = new Imagick($read_path); + + /** + * Coalesce GIF if it has many layers (animated), + * to ensure a good output. Otherwise the resulting image could + * look "corrupt". + */ if ($file_ext == 'gif' && $image->getNumberImages()) { $image = $image->coalesceImages()->current(); } + $image->cropImage($crop_width, $crop_height, $crop_left, $crop_top); $image->thumbnailImage($width, $height); + $image->setImageFormat('jpg'); $fh = fopen($write_path, 'w'); $image->writeImageFile($fh);