aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJanisPlayer <54918417+JanisPlayer@users.noreply.github.com>2023-05-03 01:18:36 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-09-02 09:30:37 +0200
commit80abec668b8e7659c3eece1b56234a3e41bc545f (patch)
tree652fecd857ff301ec75119335259432e6615ecac /lib
parent12f57ada7dd8316ef205b09aa8eaaadf0fcafefc (diff)
downloadnextcloud-server-80abec668b8e7659c3eece1b56234a3e41bc545f.tar.gz
nextcloud-server-80abec668b8e7659c3eece1b56234a3e41bc545f.zip
feat: Imaginary WebP support
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Preview/Generator.php2
-rw-r--r--lib/private/Preview/Imaginary.php20
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 4e4571f0857..b9ea5ea1a07 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -651,6 +651,8 @@ class Generator {
return 'png';
case 'image/jpeg':
return 'jpg';
+ case 'image/webp':
+ return 'webp';
case 'image/gif':
return 'gif';
default:
diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php
index da4864b1a22..7184f7e9e76 100644
--- a/lib/private/Preview/Imaginary.php
+++ b/lib/private/Preview/Imaginary.php
@@ -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'),