Skip to content

heifsave: preserve HDR NCLX with custom ICC profiles#5140

Open
gregbenz wants to merge 1 commit into
libvips:masterfrom
gregbenz:heifsave-profile-nclx
Open

heifsave: preserve HDR NCLX with custom ICC profiles#5140
gregbenz wants to merge 1 commit into
libvips:masterfrom
gregbenz:heifsave-profile-nclx

Conversation

@gregbenz

@gregbenz gregbenz commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

What

Preserve HDR NCLX when heifsave(profile=...) supplies a custom ICC profile.

libvips already asks libheif to write both ICC and NCLX colr boxes when an image contains an embedded ICC profile and complete PQ or HLG CICP signaling. This extends the same behavior to an ICC profile supplied through the profile option.

This is the focused follow-up split from #5104 during review.

Why

When profile= attaches an ICC profile, libheif defaults to writing only one colr box. Without enabling its dual-profile option, the generated NCLX profile is omitted even though the image still contains complete HDR CICP signaling.

This makes custom output profiles behave consistently with embedded ICC profiles and avoids losing explicit PQ or HLG color signaling when attaching a custom profile.

Test Plan

  • Confirm the regression test fails on current master because NCLX is absent after saving with profile=.
  • Confirm both PQ and HLG NCLX survive an AVIF save and reload with profile=.
  • Confirm the output retains both ICC and NCLX.
  • Run the full CICP and Python test suites.

Disclosure: I used an LLM to help prepare this change; I reviewed and tested it locally.

@gregbenz
gregbenz marked this pull request as ready for review July 25, 2026 21:56
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.

1 participant