How to choose the best library for uploading and converting HEIC/HEIF photos in applications?

Is there any library available that would allow me to upload both HEIC and HEIF photos, or at least convert them to another format for preview purposes?

I am currently using the file upload component from Ant Design (antd) in my project. Additionally, I’m utilizing the heic2any library to convert HEIC files to JPG, and it works well for its intended purpose. Here is the code I’m using:

const handleChange = (info) => {
    // Code to handle file upload and conversion
};

My problem arises when I encounter a HEIF file. The heic2any library doesn’t support HEIF format; it only handles HEIC files. Moreover, I’m unable to determine the file type during upload, as both HEIF and HEIC files do not seem to have a recognizable type attribute in their data when uploaded. This lack of file type recognition makes it difficult to validate and process these files correctly.

1 Like

The challenge you are facing with identifying and processing HEIF files is understandable, given that heic2any focuses on HEIC. For handling both HEIC and HEIF formats, you might need a more versatile library or a combination of tools.

One approach is to use a server-side solution for file conversion. Libraries like ImageMagick or FFmpeg have broader format support and can handle both HEIC and HEIF files. You can upload the files to your server and then use these libraries to convert them to a more common format like JPG for preview purposes.