Skip to content

feat(png)!: migrate PNG decode to gamut-png; drop zune-png - #53

Merged
justin13888 merged 1 commit into
masterfrom
32-migrate-png-decode-gamut
Jul 19, 2026
Merged

feat(png)!: migrate PNG decode to gamut-png; drop zune-png#53
justin13888 merged 1 commit into
masterfrom
32-migrate-png-decode-gamut

Conversation

@justin13888

Copy link
Copy Markdown
Collaborator

Closes #32.

Stacked on #52; merge order #42 → … → #52 → this. PNG is now gamut end-to-end.

What is Delivered

  • Decode on gamut-png's rich decode() path, normalised to Rgb16: 16-bit native passthrough (sample-exact, unit-pinned), 8-bit ×257, grayscale replication, palette expansion, alpha dropped — parity with zune verified case by case. The typed DecodeImage impls were deliberately bypassed for the main path: they're lossless-only by contract (refuse RGBA/tRNS), while rawshift's contract is decode-anything-drop-alpha. Pure gamut API either way.
  • PngDecodeConfig exposes exactly gamut's resource guards (max dimensions / image bytes / metadata bytes). The old confirm_crc/strict knobs are gone — gamut always verifies critical CRCs. DecodeOptions::Png; codec id png/gamut both directions.
  • Metadata: PNG reads now surface EXIF + ICC + XMP from DecodedPng's typed fields (old path: eXIf only). Hand-rolled chunk scanner and ExifContainer::Png deleted.
  • zune sweep: zune-png out of the lockfile; zune-core/zune-runtime remain solely for the permanent zune-ppm exception; transitive zune-jpeg held only by resvg/tiff until their migrations.

Parity note

Sub-byte grayscale (1/2/4-bit) now scales exactly per PNG §13.12; if zune differed, gamut is the spec-correct presentation.

Verification Done

Run independently after implementation: cargo test --workspace 387/0; --features full 544/0 (all 5 PNG fixture goldens incl. pixel values); --features serde 360/0; clippy workspace + full -D warnings 0+0; --no-default-features --features png standalone clean; zune-png absent from the lockfile. A png-only test-target compile failure (ungated tiff/gif helpers) was confirmed pre-existing via git stash. lefthook green.

Upstream follow-up (not filed yet)

gamut-png lacks a metadata-only entry point (gamut-jpeg has metadata()), so PNG metadata reads pay a guarded full decode — worth an upstream issue.

PNG decode moves to gamut_png::PngDecoder's rich decode() path, normalised to
interleaved Rgb16: 16-bit sources pass through natively and sample-exact
(unit-pinned), 8-bit scales x257, grayscale replicates, palettes expand, and
alpha drops — all verified at parity with the old zune behaviour. The typed
DecodeImage impls were deliberately not used for the main path: they are
lossless-only by contract and refuse RGBA/tRNS sources, while rawshift's
contract is decode-anything-drop-alpha; decode() covers the full domain
through pure gamut API.

ZunePngDecodeConfig becomes PngDecodeConfig exposing exactly gamut's resource
guards (max dimensions, max image bytes, max metadata bytes — DoS protection
the JPEG decoder currently lacks upstream, ref gamut#306). The old
confirm_crc/strict knobs are gone: gamut always verifies critical-chunk CRCs
and skips corrupt ancillary chunks per spec. DecodeOptions::PngZune -> Png;
codec id png/gamut on both directions now.

PNG metadata reads now source EXIF, ICC, and XMP from DecodedPng's typed
fields where the old path scanned eXIf alone — the hand-rolled chunk scanner
and ExifContainer::Png are deleted. zune-core/zune-runtime stay only for the
permanent zune-ppm exception; zune-png leaves the lockfile (zune-jpeg remains
transitively via resvg/tiff until their migrations).

BREAKING CHANGE: PNG decode config/variant renames; confirm_crc/strict decode
knobs removed.
Base automatically changed from 31-migrate-jpeg-gamut to master July 19, 2026 01:48
@justin13888
justin13888 merged commit 95da8ec into master Jul 19, 2026
@justin13888
justin13888 deleted the 32-migrate-png-decode-gamut branch July 19, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate PNG decode to gamut-png

1 participant