aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnna <anna@nextcloud.com>2023-02-08 11:18:36 +0100
committerGitHub <noreply@github.com>2023-02-08 11:18:36 +0100
commit6236235d23ada9f6e141f7489bd5ff069dc89c9d (patch)
tree496d9f8b4719ec548ceb6b080924f2724f1089d3 /lib
parentee05e01cf43c5e044c551340da650eed3e1c161c (diff)
parent112d516f27a0cb752e464d103dda0ba324983e3e (diff)
downloadnextcloud-server-6236235d23ada9f6e141f7489bd5ff069dc89c9d.tar.gz
nextcloud-server-6236235d23ada9f6e141f7489bd5ff069dc89c9d.zip
Merge pull request #36546 from nextcloud/enh/36543/allow-further-previews
imaginary - fix generation of heif, pdf, illustrator and svg thumbnails
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Preview/Imaginary.php63
1 files changed, 45 insertions, 18 deletions
diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php
index 0d75dbd7069..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,33 +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';
}
- $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,
+ 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(