Skip to content

Allow HEIF/AVIF saving to be compiled out - #246

Merged
danoli3 merged 1 commit into
masterfrom
feat/heif-disable-save
Nov 1, 2026
Merged

danoli3 merged 1 commit into
masterfrom
feat/heif-disable-save

Conversation

@danoli3

@danoli3 danoli3 commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Adds FREEIMAGE_HEIF_EXPORT (default ON). Configure with -DFREEIMAGE_HEIF_EXPORT=OFF to build HEIF/AVIF as read-only.

What OFF changes

  • Plugin: PluginHEIF.cpp does not compile Save, WriteEncoded, SupportsDepth or SupportsType, and Init leaves save_proc and the export callbacks unset. FreeImage_FIFSupportsWriting(FIF_HEIF/FIF_AVIF) returns FALSE and saving fails. Reading, header-only loading, ICC and Exif are unchanged.
  • Bundled libheif: Kvazaar (HEVC encoder only) is not built or linked, libheif is configured with WITH_KVAZAAR=OFF, and libaom is built with CONFIG_AV1_ENCODER=0 / WITH_AOM_ENCODER=OFF. The installed freeimage-codecs archive list follows, so the exported CMake package does not reference Kvazaar.
  • System libheif: only the plugin changes.
  • Builds without CMake default to export on; pass -DFREEIMAGE_HEIF_EXPORT=0 to opt out.

Tests

  • In a read-only build, HeifEncodingTest (HeifCodecTest --encode) now checks that both formats report no writer and no export depth, and that FreeImage_SaveToMemory fails. Before this change it skipped encoding silently whenever no writer was available.
  • bundled-codecs.yml adds read-only jobs for ubuntu-24.04 static and windows-latest shared. heif_export is a matrix key, so these entries add new jobs instead of changing existing ones.

Verified locally (macOS arm64, bundled libheif)

Export ON Export OFF
ctest 16/16 16/16
Bundled archives libaom, libde265, libheif, libkvazaar libaom, libde265, libheif
libaom.a 5.4M, aom_codec_av1_cx present 1.8M, no AV1 encoder
libheif encoder references in PluginHEIF.o 3 0
HEIF / AVIF writable yes / yes no / no

I also installed the read-only build and built the codec consumer against it. The package resolved and linked without Kvazaar. The consumer still returned 1, but only because it also requires JPEG XL and my local build left JXL out. The CI jobs build with JXL.

JPEG XL saving is not covered here. The plugin side would be the same change, but libjxl doesn't offer a decoder-only build as simply, so it should be a separate PR.

Add FREEIMAGE_HEIF_EXPORT, on by default. When it is off, PluginHEIF.cpp
does not compile Save, WriteEncoded or the export-support callbacks, so
both plugins register as read-only. Bundled builds also skip Kvazaar,
which is only an HEVC encoder, and build libaom with
CONFIG_AV1_ENCODER=0. With a system libheif only the plugin changes.

HeifEncodingTest checks that a read-only build reports no writer and
rejects saving. CI adds read-only bundled jobs on Linux and Windows.
@danoli3
danoli3 added this pull request to stack #249 November 1, 2026 00:18
@danoli3
danoli3 merged commit 113295a into master Nov 1, 2026
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant