You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just added HEIF/HEIC/AVIF support to exifi via libheif on #50. However, doing this has led to two wrinkles:
Building @exifi/image-utils in CI happens in 2m 18s compared to 1s
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:
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.
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:
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.
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.
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.
Activity
[-]Compatible Formats[/-][+]Compatible Image Formats[/+]jeremy-code commentedon Sep 11, 2026
I've just added HEIF/HEIC/AVIF support to exifi via libheif on #50. However, doing this has led to two wrinkles:
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.
jeremy-code commentedon Sep 12, 2026
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_FTYPfor 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.jeremy-code commentedon Oct 1, 2026
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_portemscripten port function as intended.Before switching to libheif, I tried a few other libraries: