Fix exported JPEG EXIF so ExifTool can rewrite tags by stripping stale RAW preview SubIFD pointers.#404
Merged
Merged
Conversation
…e RAW preview SubIFD pointers.
…o, changed it to a self containing synthetic test
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.
Summary
Fixes exported JPEG EXIF so third-party tools (notably ExifTool) can read and rewrite metadata tags.
When exporting from RAW, NegPy preserved the source EXIF via piexif, including IFD0 tags from the camera's embedded preview/thumbnail (SubIFDs, StripOffsets, preview dimensions, etc.). Those offsets are valid inside the multi-MB RAW file but invalid in a standalone JPEG APP1 block. ExifTool then failed with "Can't read SubIFD data" (and sometimes "Error reading StripOffsets data in IFD0") when writing tags such as
-UserComment=foo.Before serializing JPEG EXIF,
_prepare_jpeg_exif()now strips preview-only IFD0 tags and clears the thumbnail/1st IFD, while keeping real metadata.Test plan
uv run pytest tests/test_metadata_writer.py tests/metadata/test_writer.py -vtest_embed_strips_raw_preview_ifd_tags_from_jpeg— synthetic RAW-like EXIF; stale tags absent, Make/FocalLength preservedtest_embed_jpeg_exiftool_can_write_user_comment— synthetic RAW-like EXIF (SubIFDs/StripOffsets); ExifTool -UserComment=foo succeeds (skips if exiftool not installed)exiftool -UserComment=foo _JMB5113.jpg→1 image files updated(no SubIFD error)Fixes #402