aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-03-08 17:45:12 +0100
committerSimon L <szaimen@e.mail.de>2023-03-09 00:11:37 +0100
commitb39329c21cfbafad348127b11b7dc202a38b7308 (patch)
treedfe4994c72daee46db6f9b4ab16aa7ee62a0ab72 /lib/private
parent80e12cf72608b7c5776f02f04da98d7a5968bc73 (diff)
downloadnextcloud-server-b39329c21cfbafad348127b11b7dc202a38b7308.tar.gz
nextcloud-server-b39329c21cfbafad348127b11b7dc202a38b7308.zip
imaginary - fix autorotate and improve the logic
Signed-off-by: Simon L <szaimen@e.mail.de>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Preview/Imaginary.php65
1 files changed, 32 insertions, 33 deletions
diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php
index 5d559b65f00..ca46383e58b 100644
--- a/lib/private/Preview/Imaginary.php
+++ b/lib/private/Preview/Imaginary.php
@@ -82,8 +82,14 @@ class Imaginary extends ProviderV2 {
$httpClient = $this->service->newClient();
$convert = false;
+ $autorotate = true;
switch ($file->getMimeType()) {
+ case 'image/heic':
+ // Autorotate seems to be broken for Heic so disable for that
+ $autorotate = false;
+ $mimeType = 'jpeg';
+ break;
case 'image/gif':
case 'image/png':
$mimeType = 'png';
@@ -92,50 +98,43 @@ class Imaginary extends ProviderV2 {
case 'application/pdf':
case 'application/illustrator':
$convert = true;
+ // Converted files do not need to be autorotated
+ $autorotate = false;
+ $mimeType = 'png';
break;
default:
$mimeType = 'jpeg';
}
+
+ $operations = [];
if ($convert) {
- $operations = [
- [
- 'operation' => 'convert',
- 'params' => [
- 'type' => 'png',
- ]
- ],
- [
- 'operation' => ($crop ? 'smartcrop' : 'fit'),
- 'params' => [
- 'width' => $maxX,
- 'height' => $maxY,
- 'type' => 'png',
- 'norotation' => 'true',
- ]
+ $operations[] = [
+ 'operation' => 'convert',
+ 'params' => [
+ 'type' => $mimeType,
]
];
- } 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,
- ]
- ]
+ } elseif ($autorotate) {
+ $operations[] = [
+ 'operation' => 'autorotate',
];
}
+ $quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
+
+ $operations[] = [
+ 'operation' => ($crop ? 'smartcrop' : 'fit'),
+ 'params' => [
+ 'width' => $maxX,
+ 'height' => $maxY,
+ 'stripmeta' => 'true',
+ 'type' => $mimeType,
+ 'norotation' => 'true',
+ 'quality' => $quality,
+ ]
+ ];
+
try {
$response = $httpClient->post(
$imaginaryUrl . '/pipeline', [