Repository navigation
Add metadata stripping for image loading and saving - #243
Merged
Merged
Conversation
Add the FREEIMAGE_METADATA_STRIP CMake option, on by default. When it is off, MetadataStrip.h replaces IsStrippingMetadata() and the strip scope with constant inline stubs, so the plugin reader checks fold away, and the thread-local state and CreateStrippedView are not built. FreeImage_StripMetadata stays exported and returns FALSE, and FREEIMAGE_STRIP is still masked out of plugin flags, so the ABI and JPEG scaled-load bits are unchanged. Builds without CMake default to enabled; pass -DFREEIMAGE_METADATA_STRIP=0 to opt out. MetadataStripTest only builds when the option is on.
danoli3
force-pushed
the
feat/metadata-stripping
branch
from
November 1, 2026 00:27
7f80261 to
3064322
Compare
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.
Closes #239.
Add
FREEIMAGE_STRIPto load/save operations andFreeImage_StripMetadata()for existing bitmaps. The flag removes ICC profiles, EXIF, XMP, IPTC, comments, custom tags and thumbnails. Saving borrows the source pixels through a separate bitmap header, preserving the caller's metadata. Animation controls, transparency, palettes, resolution and the CMYK interpretation flag remain intact.Use the sign bit rather than the proposed
0x100000: that value overlaps JPEG's scaled-load size field. Strip the flag before calling plugins, propagate the policy through nested and multipage operations with thread-local scope, and honor explicitJPEG_EXIFROTATEbefore removing orientation metadata. Document the public API and behavior in README and the changelog.Security analysis: skip optional metadata readers where supported, including JPEG marker retention, PNG auxiliary chunks and TIFF/JXR metadata import. Codec libraries still parse container structures, and explicit EXIF rotation still needs EXIF parsing. Stripping an ICC profile does not convert the underlying colors.
The investigation also found that the TIFF bridge multiplied a byte-count IPTC field by four. Correct the field-type handling on read/write and add a 141-byte TIFF regression with a six-byte IPTC profile.
Validation on macOS arm64: