Skip to content

Commit

Permalink
The code has been changed for clarity
Browse files Browse the repository at this point in the history
nextcloud#38032 (comment)

Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com>
  • Loading branch information
JanisPlayer committed May 11, 2023
1 parent 7993ff3 commit f926d54
Showing 1 changed file with 13 additions and 32 deletions.
45 changes: 13 additions & 32 deletions lib/private/Preview/Imaginary.php
Expand Up @@ -84,54 +84,35 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop
$convert = false;
$autorotate = true;

$preview_format = $this->config->getSystemValueString('preview_format', 'jpeg');
switch ($file->getMimeType()) {
case 'image/heic':
// Autorotate seems to be broken for Heic so disable for that
$autorotate = false;
switch ($preview_format) {
case 'webp':
$mimeType = 'webp';
break;
default:
$mimeType = 'jpeg';
}
$mimeType = 'jpeg';
break;
case 'image/gif':
case 'image/png':
switch ($preview_format) {
case 'webp':
$mimeType = 'webp';
break;
default:
$mimeType = 'png';
}
$mimeType = 'png';
break;
case 'image/svg+xml':
case 'application/pdf':
case 'application/illustrator':
$convert = true;
// Converted files do not need to be autorotated
$autorotate = false;
switch ($preview_format) {
case 'webp':
$mimeType = 'webp';
break;
default:
$mimeType = 'png';
}
$mimeType = 'png';
break;
default:
$mimeType = 'jpeg';
}

$preview_format = $this->config->getSystemValueString('preview_format', 'jpeg');

switch ($preview_format) { // Change the format to the correct one
case 'webp':
$mimeType = 'webp';
break;
default:
switch ($preview_format) {
case 'jpeg':
$mimeType = 'jpeg';
break;
case 'webp':
$mimeType = 'webp';
break;
default:
$mimeType = 'jpeg';
}
}

$operations = [];
Expand Down

0 comments on commit f926d54

Please sign in to comment.