Apple's HEIC format is... annoying. At the moment, Apple's products are the only mainstream cameras which use it. Forums are littered with people trying to upload HEIC files to web services and failing.
So, here are four quick tips for dealing with this formal.
Display in browser
Absolutely no browser supports HEIC. Not even Apple's own browser supports it. Why?
The two teams hate each other.
— 🅨🅞🅤 ⓜⓤⓢⓣ 𝘣𝘦 𝖘𝖊𝖊𝖎𝖓𝖌 𝓽𝓱𝓲𝓷𝓰𝓼. (@ursonate) October 22, 2020
It's about 1.5MB - which is a bit abusive to your users - although it zips down to about 350KB.
The image has to be loaded into a 2D canvas to be rendered. Even on a modern laptop this is likely to take a few seconds.
There's a demo page which shows you how to get started. It's tedious, but it works.
Similarly, there's a separate library for reading HEIC metadata. This one is a much more reasonable 20KB.
That's pretty easy to use - and quick. HEIC contains pretty standard EXIF. GPS co-ordinates, camera information, that sort of thing.
Server Side - PHP
I struggled to find any libraries which were easy to use. It turns out, good old
imagick has support in modern versions.
$imagick = new Imagick(); $imagick->readImage('image.heic'); $exifArray = $imagick->getImageProperties("exif:*"); var_dump($exifArray);
Use a CDN to convert images
I use Cloud Image (Affiliate Link). Use it proxy your images. You can convert them to JPG or a modern format like WebP. It can resize and other effects.
You can write something like:
to serve your HEIC images in a more sensible format.
HEIC is a weird, patent-encumbered format. It isn't particularly useful. If you want high-quality images for editing, you probably want to shoot in RAW. If you're displaying on the web, WebP gets you a small file size and broad compatibility.
But, if you want to deal with HEIC, I hope the above was useful.