feat: Imaginary WebP support

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
JanisPlayer 2023-05-03 01:18:36 +02:00 committed by John Molakvoæ
parent 12f57ada7d
commit 80abec668b
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
2 changed files with 21 additions and 1 deletions

View file

@ -651,6 +651,8 @@ class Generator {
return 'png';
case 'image/jpeg':
return 'jpg';
case 'image/webp':
return 'webp';
case 'image/gif':
return 'gif';
default:

View file

@ -106,6 +106,15 @@ class Imaginary extends ProviderV2 {
$mimeType = 'jpeg';
}
$preview_format = $this->config->getSystemValueString('preview_format', 'jpeg');
switch ($preview_format) { // Change the format to the correct one
case 'webp':
$mimeType = 'webp';
break;
default:
}
$operations = [];
if ($convert) {
@ -121,7 +130,16 @@ class Imaginary extends ProviderV2 {
];
}
$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
switch ($mimeType) {
case 'jpeg':
$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
break;
case 'webp':
$quality = $this->config->getAppValue('preview', 'webp_quality', '80');
break;
default:
$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
}
$operations[] = [
'operation' => ($crop ? 'smartcrop' : 'fit'),