Merge pull request #1407 from AlexChambers/craft-heif/primary-item-metadata

craft-heif: items reads the primary image's EXIF and XMP; add scan for every metadata item
This commit is contained in:
FredApps authored and GitHub committed 2026-11-16 08:19:32 +01:00
commit 4ffa307f1a
5 files changed
+1938 -418

No files matched your search

Generated
+1
View File
@@ -1909,6 +1909,7 @@ name = "craft-heif"
version = "0.1.0"
dependencies = [
"heic-rs",
"proptest",
"rayon",
]
+3
View File
@@ -19,6 +19,9 @@ heic-rs = { version = "=0.1.4", default-features = false, features = ["std"], op
heic-rs = { version = "=0.1.4", default-features = false, features = ["std", "parallel"], optional = true }
rayon = { workspace = true, optional = true }
[dev-dependencies]
proptest = { workspace = true }
[features]
default = ["decode"]
# The decoder (probe, decode, decode_thumbnail, read_metadata): heic-rs for the container and HEVC.
+17 -4
View File
@@ -36,11 +36,24 @@ Errors are `Error::Unsupported` (image sequences, overlays, 4:2:2/4:4:4, …), `
`Error::Malformed`. It never panics: every call into heic-rs runs under `catch_unwind`, and a panic
inside it (PhotoCraft's fuzzing found two in 0.1.1) becomes `Error::Malformed`.
Features: `decode` (default) is the decoder above. `metadata` adds `craft_heif::items::read`: the
first `Exif` item and XMP packet from the box structure alone (`iinf`, `iloc`, `idat`; at most 4096
boxes, 1024 items, 1024 extents per item, 32 MiB per item), without heic-rs. A build with
Features: `decode` (default) is the decoder above. `metadata` adds `craft_heif::items`, which reads
the `Exif` and XMP items from the box structure alone (`pitm`, `iinf`, `iref`, `iloc`, `idat`),
without heic-rs:
- `items::read` returns the photo's own EXIF and XMP: the items `cdsc` ties to the primary image or
to an image it is made from (`dimg`: grid tiles, `iden`, `iovl`, `tmap`), else those tied to no
image. A thumbnail's or depth map's metadata is not the photo's.
- `items::scan` returns every EXIF and XMP item, whichever image it describes, and says when it
can't be sure it saw them all: `Scan::complete` is false for an incomplete or damaged item
catalog, and an item whose bytes can't be read comes back as `Unreadable`. An app that must
prove a file has no location (before an export that removes it) refuses when unsure.
- `items::exif_tiff` finds the TIFF stream in an `Exif` item, with or without a correct offset
field or an `Exif\0\0` prefix.
The reader walks at most 65,536 boxes and walks `iloc` once. It gathers at most 16 MiB per item,
and a scan gathers at most 64 MiB in all. A build with
`default-features = false, features = ["metadata"]` has no heic-rs dependency, and its
`read_metadata` is that reader. With both features, a test checks that the two readers agree.
`read_metadata` is `items::read`. With both features, a test checks that the two readers agree.
Feature `testdata` exposes `craft_heif::testdata`: lossless synthetic HEIF files (PCM-coded
32 × 32 HEVC pictures, grids, every property above) for the tests of the crates above.
+666 -414
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff