Skip to content

Compatible Image Formats #13

Open
Open

Description

@jeremy-code

Compatible Image Formats

Format Read support Write support File Notes
JPEG ✅ ✅ jpeg.cpp Read support is built into libexif. Write support is handled by libjpeg
PNG ✅ ✅ jpeg.cpp Read/write support handled by libpng. Currently, only the relatively new (2017) eXif chunk is handled.
Exif ✅ ✅ N/A Read/write support built into libexif.
WebP ✅ ✅ webp.cpp Read/write support handled by libwebp.
TIFF ❌ ❌ Probably not likely to be supported (see libvips/libvips#4518)
HEIC ✅ ❌ heif.cpp Currently, read-only support via libheif. Also, supports HEIF, AVIF.
RAW ❌ ❌
JPEG XL ❌ ❌
GIF ❌ ❌ Doesn't have Exif data at all

Tested using samples from here: https://github.com/ianare/exif-py/tree/master/tests/resources

Activity

  1. changed the title [-]Compatible Formats[/-] [+]Compatible Image Formats[/+] on Sep 7, 2026
  2. self-assigned this
    on Sep 8, 2026
  3. pinned this issue on Sep 8, 2026
  4. jeremy-code commented on Sep 11, 2026

    @jeremy-code
    OwnerAuthor

    I've just added HEIF/HEIC/AVIF support to exifi via libheif on #50. However, doing this has led to two wrinkles:

    1. Building @exifi/image-utils in CI happens in 2m 18s compared to 1s
    2. The WebAssembly bundle for @exifi/image-utils balloons from 312.03 KiB to 1.24 MiB. I tried reducing this by using the release-noplugins CMake preset (14c8a2d), but now the Netlify build errors due to a lack of memory.

    Hence, I want to try to replace libheif with something else. Here are some possible candidates:

    1. MPEGGroup/isobmff

    Unfortunately, does not seem to be under a free license.

    2. nokiatech/heif

    Under a unique license (Nokia HEIF v2.1).

    3. FFmpeg/libavformat

    Seems more geared toward video and using various formats than specifically ISOBMFF.

    4. aomediacodec/libavif

    Not sure whether it works with HEIF/HEIC.

    5. DigiDNA/ISOBMFF

    MIT license. However, currently only read-only support.

  5. jeremy-code commented on Sep 12, 2026

    @jeremy-code
    OwnerAuthor

    After a good amount of research, for now, I have settled upon replacing libheif with heicdec (518da3c) by the maintainer of Sumatra PDF. This makes the WASM binary go from 1.24 MiB 0.34 MiB.

    I tried using libavif, but unfortunately it simply returns AVIF_RESULT_INVALID_FTYP for HEIF/HEIC images even if no encoders are compiled.

    I tried reducing the bundle of libheif, but due to init.cc bringing in color conversion code, this does not seem feasible (FYI: to disable Emscripten bindings, you must set -DCMAKE_CXX_FLAGS="-D__EMSCRIPTEN_STANDALONE_WASM__"). This may be more feasible in the future if I intend to add write support via WebCodecs, but since that is not baseline yet, I don't think it's worthwhile. The alternative would be compiling something like AOM alongside libheif, which would really make the WASM binary inflate.

  6. jeremy-code commented on Oct 1, 2026

    @jeremy-code
    OwnerAuthor

    As of 62dc15a (#60) I have switched back to libheif, though with an arguably excessive bundle reduction strategy. The binary is now 657.384 (though some of that may be from other changes in C++). My main reasoning is that heicdec is not versioned, and per its README, it was also AI-assisted. I'm skeptical of the long-term support of it for now. libheif is widely regarded as the standard, so I decided to go back to it.

    I used a much more aggressive size strategy this time: enabling LTO and virtual function elimination. To avoid the strange issue I had before where build times were extremely long (I think both because of the large number of files but also the memory size usage of emcmake), I used the ports.build_port emscripten port function as intended.

    Before switching to libheif, I tried a few other libraries:

    1. GPAC - While mainly a MP4 library, it does have a part just for isomedia. The first problem is that it's a big library, I could prune the size by manually adding what files were necessary, but that's very inconvenient. Secondly, the way to handle in memory storage was by creating a new blob and using some URL (gmem?), which was a bit awkward. Probably most importantly, it still required a good amount of code to get Exif data, including iterating through all the items, which I don't think is necessary in ISOBMFF files.
    2. DigiDNA/ISOBMFF - I might reconsider this on since the API is much more convenient while still logical in regards to how the ISOBMFF container is. However, it still increased my bundle size massively.
    3. l-smash - While the current repo seems to be abandoned, vimeo has forked it: vimeo/l-smash. It also hasn't been versioned since it was fork, though it does seem to be in activate development, so this may be an option in the future, especially since it has write support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions