From bf8dddd99c6adec29c58e30697980f858c494667 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Mon, 19 Mar 2018 01:44:33 +0530 Subject: [PATCH] Not resizing gif images. See - https://github.com/Intervention/image/issues/176 Fixes #223 Signed-off-by: Abijeet --- app/Services/ImageService.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Services/ImageService.php b/app/Services/ImageService.php index 9755ea307..6686082ee 100644 --- a/app/Services/ImageService.php +++ b/app/Services/ImageService.php @@ -170,6 +170,15 @@ class ImageService extends UploadService return $image->path; } + /** + * Checks if the image is a gif. Returns true if it is, else false. + * @param Image $image + * @return boolean + */ + protected function isGif(Image $image) { + return strtolower(pathinfo($this->getPath($image), PATHINFO_EXTENSION)) === 'gif'; + } + /** * Get the thumbnail for an image. * If $keepRatio is true only the width will be used. @@ -184,6 +193,10 @@ class ImageService extends UploadService */ public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false) { + if ($keepRatio && $this->isGif($image)) { + return $this->getPublicUrl($this->getPath($image)); + } + $thumbDirName = '/' . ($keepRatio ? 'scaled-' : 'thumbs-') . $width . '-' . $height . '/'; $imagePath = $this->getPath($image); $thumbFilePath = dirname($imagePath) . $thumbDirName . basename($imagePath);