From 0647f8c810d2341c7edd7e7c9b414f324daeac4b Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Fri, 25 Mar 2022 09:43:38 +0100 Subject: [PATCH] Ensured that the package icon is always in the required jpeg format --- src/Package/PackageHelper.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Package/PackageHelper.php b/src/Package/PackageHelper.php index 17de4f1..10f9d1b 100644 --- a/src/Package/PackageHelper.php +++ b/src/Package/PackageHelper.php @@ -25,6 +25,7 @@ use finfo; use Imagick; use ImagickException; +use ImagickPixel; use InvalidArgumentException; @@ -153,6 +154,15 @@ public static function createThumbnail(string $logoImageData): string $image = new Imagick(); $image->readImageBlob($logoImageData); $image->cropThumbnailImage(self::THUMBNAIL_SIZE, self::THUMBNAIL_SIZE); + + //ensures that the thumbnail is in jpeg data format as it is currently required for OMM remote repositories + $image->setImageFormat('jpeg'); + $image->setImageCompression(imagick::COMPRESSION_JPEG); + $image->setCompressionQuality(60); + + // set default background color in case there is an alpha image in the source + $image->setImageBackgroundColor(new ImagickPixel('white')); + $scaledImage = $image->getImageBlob(); $image->destroy(); return $scaledImage;