We all have long known the JPEG file format because it is quite old already, and just works everywhere. Back in the day it offered a reasonable compression, being a lossy compression, but it is probably no longer the best format to use. Whilst PNG is a lossless format, so offers better quality than JPEG, its file sizes are even larger than JPEG, so it is generally not found in camera apps as an option to save photos.
Although HEIC is best known for being adopted by Apple across its products from 2017, it was actually finalised in mid-2015 by MPEG (the Moving Pictures Expert Group). The actual encoding format used, is called HEVC, and it is for both image and video encoding. Today, Samsung, Google, Canon, Sony, Qualcomm, and some others also support it.
Not only does HEIC offer better compression than JPEG without sacrificing image quality (meaning also much smaller file sizes), but an HEIC file also carries an alpha channel to store pictures with transparency, a depth map to store LiDAR scans, depth estimations, and more. Overall, it offers more versatility than a JPG file.
I’ve long just stuck with JPEG out of fear of losing compatibility, but I tested HEIC today a bit, and it is reading just fine on my Linux computer, and it saves fine on my Samsung phone too. I’ve uploaded the HEIC photo to Google Photos, and it reads it fine too. On my phone, a JPEG photo takes up 3.9 MB and the identical resolution photo in HEIC is 2.6 MB (about a 40% saving). In general, though, the average saving can be about 50%. That translates not only into less storage space, but also quicker uploads and file transfers too. RAW is another alternative for really high quality (more for pro-photographers), but as it is completely uncompressed, the file sizes are generally around five times larger than HEIC.
While Apple (and Samsung) only uses the .heic format on iPhones and tablets, several other associated extensions exist. For example, Canon and Sony prefer .hif. The rest of the file extensions are .heif, .heifs, .heics, .avifs, .avif, .avci, and .avcs. I seem to recall, too, that Apple saves additional quality features into its HEIC format photos versus into using the JPEG compatible format.
And related to this as well, is the images used on webpages, because again it has been JPEG as the default for many years.
Whilst HEIC is often now used for camera image and video storage, webpages have started to make use of the WEBP format (not intended for cameras). Both JPEG and WEBP are lossy compression formats (because web images are generally not ultra-high resolution, as load times are preferred over quality) and WEBP is said to be about 25-35% smaller size than JPEG. I downloaded 3 sample photos in JPEG and WEBP, and on average the WEBP is about 30% smaller. Mostly all modern browsers support WEBP today. There is an even newer format than WEBP, called AVIF, which could be 50% smaller than JPEG for web publishing, but support is not yet broadly available for it across all browsers.
So JPEG does probably offer 100% compatibility everywhere, but if you can use HEIC for camera photos and videos (check whether your computer requires an extension to be installed) it is probably well worth doing so. The same really goes for WEBP for websites where the images are for viewing in a browser (images intended to be downloaded for printing should probably still be in JPEG format).
It is probably time for us to default to using HEIC where we can on our cameras for day-to-day photography in place of JPEG. HEIC is not ideal though for web publishing, so for that, WEBP is a better alternative than JPEG.