Merge pull request #1553 from gaincoder/v3.0

Add .webp support and fix #1467
This commit is contained in:
Diego Najar 2024-01-28 20:13:39 +01:00 committed by GitHub
commit d586fce4f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 204 additions and 195 deletions

View file

@ -932,7 +932,7 @@ function transformImage($file, $imageDir, $thumbnailDir = false)
// Generate Thumbnail
if (!empty($thumbnailDir)) {
if (($fileExtension == 'svg') || ($fileExtension == 'webp')) {
if (($fileExtension == 'svg')) {
Filesystem::symlink($image, $thumbnailDir . $nextFilename);
} else {
$Image = new Image();

View file

@ -62,6 +62,12 @@ class Image {
imagepng($this->imageResized, $path_complete, $invertScaleQuality);
}
break;
case 'webp':
// Checking for JPG support
if (imagetypes() & IMG_WEBP) {
imagewebp($this->imageResized, $path_complete, $imageQuality);
}
break;
default:
// Fail extension detection
@ -88,6 +94,9 @@ class Image {
case '.png':
$img = imagecreatefrompng($file);
break;
case '.webp':
$img = imagecreatefromwebp($file);
break;
default:
$img = false;
break;