aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-03-10 16:17:30 +0100
committerGitHub <noreply@github.com>2023-03-10 16:17:30 +0100
commit8b088b3e330c5309d3d818a2d54f93dcf6ecae35 (patch)
tree14af82462458faa9d6132d804b02f15d811abfdc /lib/private
parent598e19f1302feb97bee28db46522ae81065950fa (diff)
parentf7faf8997cbde0c65c55470896be2d38f9a3861d (diff)
downloadnextcloud-server-8b088b3e330c5309d3d818a2d54f93dcf6ecae35.tar.gz
nextcloud-server-8b088b3e330c5309d3d818a2d54f93dcf6ecae35.zip
Merge pull request #37156 from nextcloud/backport/37140/stable25
[stable25] imaginary - fix autorotate for heic and improve the logic
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', [