Skip to content

Commit

Permalink
imaginary - allow to generate heif, pdf and svg thumbnails
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <[email protected]>
  • Loading branch information
szaimen committed Feb 5, 2023
1 parent 2ddd7f5 commit a223d08
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/private/Preview/Imaginary.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function getMimeType(): string {
}

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|webp)|application\/pdf)/';
}

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

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

$operations = [];

switch ($file->getMimeType()) {
case 'image/gif':
case 'image/png':
$mimeType = 'png';
break;
case 'image/svg':
case 'application/pdf':
$mimeType = 'png';
$operations = [
[
'operation' => 'convert',
'params' => [ 'type' => $mimeType, ]
]
];
break;
default:
$mimeType = 'jpeg';
}

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

$operations = [
$operations[] = [
[
'operation' => 'autorotate',
],
Expand Down

0 comments on commit a223d08

Please sign in to comment.