Repository navigation
Allow JPEG XL saving to be compiled out, and add FREEIMAGE_CODEC_EXPORT - #247
Merged
Merged
Conversation
Add FREEIMAGE_JXL_EXPORT, on by default. When it is off, PluginJPEGXL.cpp does not include jxl/encode.h or compile Save and the export-support callbacks, so the plugin registers as read-only. Nothing then references libjxl's encoder, and the linker leaves it out of FreeImage. Add FREEIMAGE_CODEC_EXPORT, on by default, which turns off saving for HEIF/AVIF and JPEG XL together. The per-codec compile definitions now come from one rule in the codec loop. JpegXLTest checks that a read-only build reports no writer and rejects saving, and runs header-only and truncated loads on a fixture. The read-only CI jobs now use FREEIMAGE_CODEC_EXPORT=OFF.
Owner
Author
Size differenceShared
The two per-codec savings add up to roughly the combined one, so they don't overlap. What drops out:
All 16 ctest tests pass in every configuration. Static builds should save the same amount once a consumer links them, but I haven't measured that. Windows and Linux sizes aren't measured either; the read-only CI jobs check that those builds work, not how big they are. |
Add read-only jobs for FREEIMAGE_HEIF_EXPORT=OFF alone (macOS shared) and FREEIMAGE_JXL_EXPORT=OFF alone (Ubuntu shared), next to the existing FREEIMAGE_CODEC_EXPORT=OFF jobs. Every include entry sets all three export keys, because a new job gets only the keys it lists and an empty value would turn that codec off as well. The codec consumer now takes optional expected writer support for HEIF/AVIF and JPEG XL. CI derives the expectation from the matrix rather than from CMake, so a broken FREEIMAGE_CODEC_EXPORT override fails the job. Without arguments the consumer behaves as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #246. The base branch is
feat/heif-disable-save, so this diff only shows the JPEG XL and master-switch changes. Once #246 merges, GitHub retargets this PR tomaster.Options
FREEIMAGE_CODEC_EXPORTFREEIMAGE_HEIF_EXPORTFREEIMAGE_JXL_EXPORTWhen
FREEIMAGE_CODEC_EXPORTis OFF, both per-codec switches are forced off. The per-codec compile definitions now come from one rule in the codec loop:FREEIMAGE_<codec>_EXPORT=0.The master switch is named
FREEIMAGE_CODEC_EXPORT, notFREEIMAGE_EXPORT, becauseFREEIMAGE_EXPORTSis already the dllexport define for shared Windows builds.JPEG XL
PluginJPEGXL.cppdoes not includejxl/encode.hor compileSave,DepthorType, andsave_procand the export callbacks stay unset.FreeImage_FIFSupportsWriting(FIF_JPEGXL)returns FALSE and saving fails. Loading is unchanged.jxl_declibrary, and with nothing referencingJxlEncoder*the linker leaves the encoder out of FreeImage anyway (measured below). Linkingjxl_decfrom libjxl's build tree would only save build time.Tests
JpegXLTestchecks that JPEG XL reports no writer or export depth and that saving fails. Because the lossless round trips can't encode, the header-only and truncated-input checks run on the checked-inlossy.jxlfixture instead. The lossy/progressive/upsampled fixture decodes still run in both modes.bundled-codecs.ymljobs added in Allow HEIF/AVIF saving to be compiled out #246 now pass-DFREEIMAGE_CODEC_EXPORT=OFF, so they cover both codecs.Verified locally (macOS arm64, shared library, bundled libheif and libjxl)
Same commit for every row; only the export options differ. All 16 ctest tests pass in every configuration.
libFreeImage.dylibFREEIMAGE_JXL_EXPORT=OFFFREEIMAGE_HEIF_EXPORT=OFFFREEIMAGE_CODEC_EXPORT=OFFThe two per-codec savings add up to roughly the combined one.
JxlEncoder*symbolsaom_codec_av1_cx)kvz_api_get)With HEIF export off, the bundled
libaom.aalone goes from 5.4 MB to 1.8 MB. One libheif symbol,heif_context_encode_image, remains in read-only builds. It's part of libheif's own public API and stays compiled into libheif, but FreeImage doesn't call it. Static, Windows and Linux sizes are not measured.