From 768f834ea159dfdc83eec56f776b2630d0335ae3 Mon Sep 17 00:00:00 2001 From: celestora Date: Wed, 14 Dec 2022 23:09:25 +0200 Subject: [PATCH] Use hermite filter instead of point for image resize Fixes terrific image distortion during downscaling --- Web/Models/Entities/Photo.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Web/Models/Entities/Photo.php b/Web/Models/Entities/Photo.php index 5627a4fe..454be7f8 100644 --- a/Web/Models/Entities/Photo.php +++ b/Web/Models/Entities/Photo.php @@ -39,13 +39,13 @@ class Photo extends Media if(isset($size["maxSize"])) { $maxSize = (int) $size["maxSize"]; $sizes = Image::calculateSize($image->getImageWidth(), $image->getImageHeight(), $maxSize, $maxSize, Image::SHRINK_ONLY | Image::FIT); - $image->resizeImage($sizes[0], $sizes[1], \Imagick::FILTER_POINT, 1); + $image->resizeImage($sizes[0], $sizes[1], \Imagick::FILTER_HERMITE, 1); } else if(isset($size["maxResolution"])) { $resolution = explode("x", (string) $size["maxResolution"]); $sizes = Image::calculateSize( $image->getImageWidth(), $image->getImageHeight(), (int) $resolution[0], (int) $resolution[1], Image::SHRINK_ONLY | Image::FIT ); - $image->resizeImage($sizes[0], $sizes[1], \Imagick::FILTER_POINT, 1); + $image->resizeImage($sizes[0], $sizes[1], \Imagick::FILTER_HERMITE, 1); } else { throw new \RuntimeException("Malformed size description: " . (string) $size["id"]); } @@ -107,7 +107,7 @@ class Photo extends Media $sizes = Image::calculateSize( $image->getImageWidth(), $image->getImageHeight(), 8192, 4320, Image::SHRINK_ONLY | Image::FIT ); - $image->resizeImage($sizes[0], $sizes[1], \Imagick::FILTER_POINT, 1); + $image->resizeImage($sizes[0], $sizes[1], \Imagick::FILTER_HERMITE, 1); $image->writeImage($this->pathFromHash($hash)); $this->saveImageResizedCopies($image, $filename, $hash);