summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-02-08 13:49:19 +0100
committerGitHub <noreply@github.com>2023-02-08 13:49:19 +0100
commit517698cb62fdf3ca8b3b8b105b25d7213e880d6b (patch)
tree605d3f3028c8adc5c3d59d618017b073fbd81d71
parent3306f66ece7af461aa0bd72982fbc7e2db44c10b (diff)
parent7acda5fab6dab02b14e9b4094d330b71a176f437 (diff)
downloadnextcloud-server-517698cb62fdf3ca8b3b8b105b25d7213e880d6b.tar.gz
nextcloud-server-517698cb62fdf3ca8b3b8b105b25d7213e880d6b.zip
Merge pull request #36602 from nextcloud/backport/36546/stable25
[stable25] imaginary - fix generation of heif, pdf, illustrator and svg thumbnails
-rw-r--r--lib/private/Preview/Imaginary.php60
1 files changed, 45 insertions, 15 deletions
diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php
index 532fcf2247a..5d559b65f00 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,30 +81,60 @@ 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';
}
- $operations = [
- [
- 'operation' => 'autorotate',
- ],
- [
- 'operation' => ($crop ? 'smartcrop' : 'fit'),
- 'params' => [
- 'width' => $maxX,
- 'height' => $maxY,
- 'stripmeta' => 'true',
- 'type' => $mimeType,
- 'norotation' => 'true',
+ if ($convert) {
+ $operations = [
+ [
+ 'operation' => 'convert',
+ 'params' => [
+ 'type' => 'png',
+ ]
+ ],
+ [
+ 'operation' => ($crop ? 'smartcrop' : 'fit'),
+ 'params' => [
+ 'width' => $maxX,
+ 'height' => $maxY,
+ 'type' => 'png',
+ '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(