Playing with HEIC images in lossless mode

One of the most interesting features of the new HEIF/HEIC image format — and a true expected innovation — is lossless compression.

Before the HEIC era, to chose between lossy or lossless required the user to completely switch between image file formats:

  • You had to chose lossy (JPEG) if you needed small file size, loosing other features such as alpha channel (transparency). Not to mention to loose forever the original information about your subject. And loosing even more every time you edit your photos.
  • You had to chose lossless (PNG, TIFF) if you needed alpha channel and pixel perfectness for computer-generated samples. Having to deal with potentially bigger file sizes and formats not popular with EXIF, XMP and IPTC tags and metadata.

The new HEIF format with HEVC (H.265) compression (HEIC) unifies all of that. One single industry-standard image format can handle:

  • advanced lossy and lossless with high compression rates for the smallest possible file sizes
  • transparency and alpha channel
  • animations (remember GIF ?)
  • photo metadata with EXIF, XMP, IPTC and MPEG-4 style info

I used macOS 10.13.6 plain Preview app to convert some pictures and photos to lossless HEIF/HEVC. The conversion is of very high quality, preserving all original files metadata. These are the impressive results:

Original file size in bytes Lossless HEIC file size in bytes Compression rate Picture dimensions Source image type
19,572,288 13,898,345 71.01% 6016×4016 Nikon DSLR camera raw photo processed by Adobe tools and saved as DNG
22,250,018 7,367,322 33.11% 4352×3264 Unprocessed Canon G1X raw photo (CR2)
3,208,062 7,251,778 226.05% 4032×3024 iPhone X regular unprocessed JPEG photo
635,773 424,807 66.82% 6452×3326 Large computer-generated PNG file with gradients and alpha channel
5,031 103,514 2057.52% 600×600 Small computer-generated PNG file with gradients and alpha channel
21,141,605 8,537,321 40.38% 5891×2271 PNG created from a JPEG photo

As you can see, HEIF/HEIC lossless compression provides significantly smaller files when compared to other lossless formats. As pointed above, better compression is just one of the benefits of this new format. Standardisation and a single format to all needs are other benefits.

HEIF is considerably more difficult to handle by programers. But this is a limitation that will be surpassed over time.

About patents, HEIF and HEVC are completely free if used as software only. It means your camera manufacturer will have to pay royalties to the format creators, but computer software creators and users are free to use it.

Having said that, we are wasting our time still using old inefficient image formats as JPEG, TIFF, DNG and PNG for most use cases. Lets move to HEIF/HEIC.

Original and converted pictures used in this analysis are here.

3 thoughts on “Playing with HEIC images in lossless mode

  1. > About patents, HEIF and HEVC are completely free if used as software only. It means your camera manufacturer will have to pay royalties to the format creators, but computer software creators and users are free to use it.

    This is a very misleading statement. There is an patent licence exception for free-as-in-beer software implementing HEVC patented features, from the HEVC Advance pool only, and not the two other patent licensing pools.

    Regardless, a “free as in beer” exception, even if it were offered by all patent pools, is not compatible with libre software generally, as it effectively imposes an additional restriction on charging for libre software. The fee waiver also *only* applies when the software is *not bundled* with hardware.

    > Lets move to HEIF/HEIC.

    So no, let’s not. It has serious patent problems.

    AVIF has some potential, as the equivalent still image format from AV1 https://en.wikipedia.org/wiki/AV1#AV1_Still_Image_File_Format_(AVIF). Maybe you might want to consider investigating that.

    1. Bob, I’m aware of AV1. I see it as a format still being developed and not in plans to be adopted by anybody. While HEIC is already there, in Apple, Windows and entering camera manufacturer domains.

      I might have indeed incomplete/incorrect information about HEIC IP issues. Even so, I think HEIC is the best think we currently have as an image format. It solves every single problem of older formats, but the IP one. And being widely adopted, open source software will be also widely available and IP constrains will be practically mitigated. As happened with MP3.

Leave a Reply

Your email address will not be published.