Skip to content

Commit

Permalink
Merge pull request nextcloud#38032 from JanisPlayer/master
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Sep 2, 2023
2 parents 12f57ad + 80abec6 commit 382d791
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ private function getExtension($mimeType) {
return 'png';
case 'image/jpeg':
return 'jpg';
case 'image/webp':
return 'webp';
case 'image/gif':
return 'gif';
default:
Expand Down
20 changes: 19 additions & 1 deletion lib/private/Preview/Imaginary.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop
$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:
}

$operations = [];

if ($convert) {
Expand All @@ -121,7 +130,16 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop
];
}

$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
switch ($mimeType) {
case 'jpeg':
$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
break;
case 'webp':
$quality = $this->config->getAppValue('preview', 'webp_quality', '80');
break;
default:
$quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
}

$operations[] = [
'operation' => ($crop ? 'smartcrop' : 'fit'),
Expand Down

0 comments on commit 382d791

Please sign in to comment.