summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-02-05 16:44:27 +0100
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-02-08 10:27:40 +0000
commitcadbccd7c72036c503b9376f3615ddacc9b77f08 (patch)
tree7cb85ab9e49efd8b867107914ca02160d21123bc
parentb32b9eb540403ac316639beb5cc67a1fc48d03f0 (diff)
downloadnextcloud-server-cadbccd7c72036c503b9376f3615ddacc9b77f08.tar.gz
nextcloud-server-cadbccd7c72036c503b9376f3615ddacc9b77f08.zip
imaginary - allow to generate heif, pdf and svg thumbnails
Signed-off-by: Simon L <szaimen@e.mail.de>
-rw-r--r--lib/private/Preview/Imaginary.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php
index 532fcf2247a..884122ef54a 100644
--- a/lib/private/Preview/Imaginary.php
+++ b/lib/private/Preview/Imaginary.php
@@ -57,7 +57,7 @@ class Imaginary extends ProviderV2 {
}
public static function supportedMimeTypes(): string {
- return '/image\/(bmp|x-bitmap|png|jpeg|gif|heic|svg|tiff|webp)/';
+ return '/(image\/(bmp|x-bitmap|png|jpeg|gif|heic|heif|svg\+xml|tiff|webp)|application\/(pdf|illustrator))/';
}
public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop): ?IImage {
@@ -81,11 +81,18 @@ class Imaginary extends ProviderV2 {
$httpClient = $this->service->newClient();
+ $convert = false;
+
switch ($file->getMimeType()) {
case 'image/gif':
case 'image/png':
$mimeType = 'png';
break;
+ case 'image/svg+xml':
+ case 'application/pdf':
+ case 'application/illustrator':
+ $convert = true;
+ break;
default:
$mimeType = 'jpeg';
}
@@ -103,8 +110,27 @@ class Imaginary extends ProviderV2 {
'type' => $mimeType,
'norotation' => 'true',
]
- ]
- ];
+ ];
+ } else {
+ $quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
+
+ $operations = [
+ [
+ 'operation' => 'autorotate',
+ ],
+ [
+ 'operation' => ($crop ? 'smartcrop' : 'fit'),
+ 'params' => [
+ 'width' => $maxX,
+ 'height' => $maxY,
+ 'stripmeta' => 'true',
+ 'type' => $mimeType,
+ 'norotation' => 'true',
+ 'quality' => $quality,
+ ]
+ ]
+ ];
+ }
try {
$response = $httpClient->post(