feat: use webp by default, falling back to jpeg (#1574)

This commit is contained in:
Phan An 2022-11-03 13:46:54 +01:00 committed by GitHub
parent 28b9a55453
commit 4854e56fdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@
namespace App\Services;
use Intervention\Image\Constraint;
use Intervention\Image\Exception\NotSupportedException;
use Intervention\Image\ImageManager;
class ImageWriter
@ -31,6 +32,10 @@ class ImageWriter
$img->blur($config['blur']);
}
$img->save($destination, $config['quality'] ?? self::DEFAULT_QUALITY);
try {
$img->save($destination, $config['quality'] ?? self::DEFAULT_QUALITY, 'webp');
} catch (NotSupportedException) {
$img->save($destination, $config['quality'] ?? self::DEFAULT_QUALITY);
}
}
}