Skip to content

Commit a223d08

Browse files
committed
imaginary - allow to generate heif, pdf and svg thumbnails
Signed-off-by: Simon L <szaimen@e.mail.de>
1 parent 2ddd7f5 commit a223d08

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/private/Preview/Imaginary.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getMimeType(): string {
5757
}
5858

5959
public static function supportedMimeTypes(): string {
60-
return '/image\/(bmp|x-bitmap|png|jpeg|gif|heic|svg|tiff|webp)/';
60+
return '/(image\/(bmp|x-bitmap|png|jpeg|gif|heic|heif|svg|webp)|application\/pdf)/';
6161
}
6262

6363
public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop): ?IImage {
@@ -81,18 +81,30 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop
8181

8282
$httpClient = $this->service->newClient();
8383

84+
$operations = [];
85+
8486
switch ($file->getMimeType()) {
8587
case 'image/gif':
8688
case 'image/png':
8789
$mimeType = 'png';
8890
break;
91+
case 'image/svg':
92+
case 'application/pdf':
93+
$mimeType = 'png';
94+
$operations = [
95+
[
96+
'operation' => 'convert',
97+
'params' => [ 'type' => $mimeType, ]
98+
]
99+
];
100+
break;
89101
default:
90102
$mimeType = 'jpeg';
91103
}
92104

93105
$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
94106

95-
$operations = [
107+
$operations[] = [
96108
[
97109
'operation' => 'autorotate',
98110
],

0 commit comments

Comments
 (0)