Unsupported image type image/heic. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files
cotiga opened this issue · 3 comments
Laravel version
9.4
PHP version
8.2
Voyager version
1.6
Database
Mysql 8
Description
According to my research intervention/image in version 2 does not support the HEIC format. But version 3 does, by adding a portion of code.
I wanted to know if it is possible to install version 3 and if it would work with Voyager?
Steps to reproduce
Upload an image from an iPhone
Expected behavior
I wanted to know if it is possible to install version 3 and if it would work with Voyager?
Screenshots
No response
Additional context
No response
https://image.intervention.io/v3/introduction/upgrade
I'm going to say not directly, not without going over the upgrade guide and changing a bunch of methods/service provider, maybe caching. Things like encode() are used at the very least, but you'd have to search though and find if/what needs to be changed.
https://github.com/thedevdojo/voyager/blob/7866a2d287c72b2682322d84f691974eb68c9331/src/Http/Controllers/ContentTypes/Image.php#L92C1-L95C92
I'm working on it, will keep you informed
I found that :
if ($file->getClientOriginalExtension() == 'heic') {
$file = $request->file('image')
$manager = new ImageManager(Driver::class);
$image = $manager->read($file);
$filename = uniqid() . time() . rand(10, 1000000) . '.jpg';
$image->toJpeg()->save('storage/images/'.$filename);
}
This might be hacky, but you could potentially create middleware that would catch the upload request,
Use https://github.com/MaestroError/php-heic-to-jpg
and then pass the transformed jpg on.