image: fix editing png

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/672/head
Varun Patil 2023-05-28 00:58:45 -07:00
parent bfce0b06ad
commit 8899021c96
1 changed files with 9 additions and 3 deletions

View File

@ -296,7 +296,7 @@ class ImageController extends GenericApiController
string $name,
int $width,
int $height,
float $quality,
?float $quality,
string $extension,
array $state
): Http\Response {
@ -334,9 +334,15 @@ class ImageController extends GenericApiController
$image->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, true);
}
// Save the image
// Set image format
$image->setImageFormat($extension);
$image->setImageCompressionQuality((int) round(100 * $quality));
// Set quality if specified
if (null !== $quality && $quality >= 0 && $quality <= 1) {
$image->setImageCompressionQuality((int) round(100 * $quality));
}
// Save the image
$blob = $image->getImageBlob();
// Save the file