Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported image type image/heic. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files #5831

Open
cotiga opened this issue Jan 6, 2024 · 3 comments

Comments

@cotiga
Copy link
Contributor

cotiga commented Jan 6, 2024

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

@Emerica
Copy link
Contributor

Emerica commented Jan 6, 2024

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

@cotiga
Copy link
Contributor Author

cotiga commented Jan 6, 2024

I'm working on it, will keep you informed

I found that :

Intervention/image#1230

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);
}

@Emerica
Copy link
Contributor

Emerica commented Jan 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants