Repository navigation
Add EXIF carry-over and embedded thumbnail decoding - #6
Merged
Merged
Conversation
convertHeic takes exif: 'none' | 'all' | 'no-location'. Copied EXIF gets Orientation reset to 1 and PixelX/YDimension set to the output size, since the pixels are already upright; leaving the iPhone's Orientation in place makes viewers rotate a second time. 'no-location' drops the GPS IFD pointer and zeroes every GPS byte, and fails closed on a block it cannot walk. Any Exif APP1 the encoder wrote (WebKit adds one) is replaced, not duplicated. decodeHeicThumbnail decodes the thmb item with WebCodecs and falls back to a downscaled primary; 4 of 9 recent iPhone photos in the local corpus have no thumbnail at all. readExif returns the raw TIFF block. New synthetic fixture exif-thumb.heic (fake GPS, Orientation 6, irot 270, 96 px thumbnail). exifr is a dev dependency so the tests check output with an independent parser rather than our own reader.
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.
What
convertHeic(file, { exif: 'none' | 'all' | 'no-location' }), default'none'(unchanged behavior). Copied EXIF has Orientation reset to 1 and pixel dimensions set to the output size, since the pixels are already upright.'no-location'removes the GPS block and zeroes its bytes.ConvertedImage.exifreports what was actually written.decodeHeicThumbnail(file)decodes the embeddedthmbthumbnail with WebCodecs, falling back to a downscaled primary when there is none (common on recent iPhones) or it cannot be decoded.readExif(file)returns the raw EXIF TIFF block.planItemandfindThumbnailItemIdexported for advanced use.Minor changeset included, so merging produces the 0.3.0 release PR.
Details worth reviewing
'no-location'mode.new Uint8Array(view), because.slice()on a Node Buffer returns a view and would mutate the caller's bytes (caught by a test).decodeHeiccan tree-shake the EXIF code.Testing
exifras the independent parser.chrome-hevc): 137 passed, 0 skipped, including thumbnails of 9 real iPhone photos from the local corpus.exif: 'no-location': exiftool shows Orientation normal, 600x800 dims matching the pixels, no GPS (source has GPS), and the image is upright when viewed.