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

Accept HEIC/HEIF Uploads and Convert them to JPEG #785

Open
macmanx2 opened this issue Jan 22, 2025 · 2 comments
Open

Accept HEIC/HEIF Uploads and Convert them to JPEG #785

macmanx2 opened this issue Jan 22, 2025 · 2 comments

Comments

@macmanx2
Copy link
Contributor

iOS and iPadOS devices now store images as HEIC by default.

As long as "Automatic" or "Most Compatible" is seletect in the browser's upload sheet, the device will convert to JPEG on upload, but if "Current" is selected or the uploader is dragging and dropping from the Photos app on their Mac, an HEIC file will be uploaded and refused.

A big problem with HEIC is that only Safari supports displaying it https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format#Support so many services simply don't accept it.

A few services do accept HEIC and take on the conversion to JPEG themselves, and maybe MLTSHP could be one of them.

My knowledge in this space is unfortunately limited to just research, but here's how WordPress does HEIC conversion to JPEG on upload:

They experimented with client-side processing but ran into some licensing issues WordPress/gutenberg#61447 but maybe this is something that Fastly could do for us? https://www.fastly.com/documentation/reference/io/

I also asked @newbold who runs https://some.pics which converts HEIC uploads to JPEG, and he gave permission to share that they use heif-convert as a command line utility:

// convert heic/heif if($mime === 'image/heic' || $mime === 'image/heif') { $uploaded_pic_jpg = tempnam("/tmp", "some.pics.jpg."); $convert = shell_exec("heif-convert $uploaded_pic $uploaded_pic_jpg.jpg"); $uploaded_pic = $uploaded_pic_jpg.'.jpg'; $mime = 'image/jpeg'; unlink($uploaded_pic_jpg); }

@bradchoate
Copy link
Collaborator

IMHO, uploaded images should go into our block storage unaltered. I think Fastly would be the way to go for the transformation step. They support HEIC and others. So if we tack ?format=auto to the image URLs, it should just work. We can just increase the mime types we permit to be uploaded for images. So, we can be liberal in what we accept and conservative in what we send. If it is a type of file that we cannot directly handle with Pillow (for making resized 'small', 'thumbnail' variants), we could use Fastly for those as well. I've been thinking about doing just that so we don't have to make those variants at all, but haven't done that yet.

@soupkills
Copy link

There's also https://github.com/bigcat88/pillow_heif if we decide to use Pillow.

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

No branches or pull requests

3 participants