Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-HDR-EXPORT: say how viewers without cICP show a PQ PNG

JordyUSAc9c0268f8b68
diff --git a/crates/codecs/src/encode.rs b/crates/codecs/src/encode.rs
index c4d8fe0ad..02ba7b319 100644
--- a/crates/codecs/src/encode.rs
+++ b/crates/codecs/src/encode.rs
@@ -503,7 +503,8 @@ pub fn encode_avif_pq(width: u32, height: u32, rgb: &[f32], quality: u8, speed:
/// (SDR white at [`HDR_REFERENCE_WHITE_NITS`]), described by a `cICP` chunk (PNG third edition:
/// BT.2020 primaries, PQ, RGB, full range) and a `cLLI` content light level chunk (the same
/// levels the HDR AVIF records). EXIF and XMP are embedded; an ICC profile is not (`cICP`
-/// describes the colour, and readers prefer it).
+/// describes the colour, and readers prefer it). Readers without `cICP` support show the PQ
+/// samples as if they were sRGB (flat, washed out): expected for a PQ PNG, there is no fallback.
pub fn encode_png_pq(width: u32, height: u32, rgb: &[f32], meta: &EncodeMeta) -> Result<Vec<u8>> {
let (w, h) = (width as usize, height as usize);
let n = w.checked_mul(h).ok_or_else(|| Error::Encode("image too large".into()))?;
diff --git a/crates/engine/src/export.rs b/crates/engine/src/export.rs
index 51e2f0341..e71750f3e 100644
--- a/crates/engine/src/export.rs
+++ b/crates/engine/src/export.rs
@@ -602,7 +602,8 @@ pub struct ExportOptions {
pub bit_depth: Option<u8>,
/// HDR output for photos edited in HDR: JPEG as an ISO 21496-1 gain map JPEG (the SDR
/// rendition plus a gain map, so the file looks right everywhere; quality as set, `limit_kb`
- /// not applied), AVIF as 10-bit Rec. 2020 PQ, PNG as 16-bit Rec. 2020 PQ (`cICP`), 32-bit float
+ /// not applied), AVIF as 10-bit Rec. 2020 PQ, PNG as 16-bit Rec. 2020 PQ (`cICP`; viewers
+ /// without cICP support show it as sRGB, washed out), 32-bit float
/// TIFF with the highlights above SDR white kept. Other formats, and photos without an HDR
/// edit, are SDR.
pub hdr: bool,
diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rs
index 561f1578c..7cb55223d 100644
--- a/crates/ui-egui/src/panels/dialogs.rs
+++ b/crates/ui-egui/src/panels/dialogs.rs
@@ -564,7 +564,8 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
} else if opts.format == F::Avif && opts.hdr {
ui.label(egui::RichText::new("Color space: Rec. 2020 PQ (HDR AVIF)").color(t.text_dim));
} else if opts.format == F::Png && opts.hdr {
- ui.label(egui::RichText::new("Color space: Rec. 2020 PQ, 16-bit (HDR PNG)").color(t.text_dim));
+ ui.label(egui::RichText::new("Color space: Rec. 2020 PQ, 16-bit (HDR PNG)").color(t.text_dim))
+ .on_hover_text("Viewers that don't read the PNG cICP chunk show PQ values as sRGB: flat and washed out. For a picture that looks right everywhere, use JPEG (gain map).");
} else if opts.format == F::Avif {
ui.label(egui::RichText::new(crate::i18n::tr("Color space: sRGB (AVIF)")).color(t.text_dim));
} else {
diff --git a/docs/whats-new.md b/docs/whats-new.md
index f3fb3a143..ebd41a569 100644
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@ -13,6 +13,14 @@
## 2026-10-09
+### HDR PNG export
+- With **HDR output** on, a photo edited in HDR can now be exported as a **16-bit PNG** with the PQ curve in Rec. 2020,
+ like the HDR AVIF: the same brightness, with SDR white at 203 cd/m², and content light levels recorded.
+- The colour is described by the PNG `cICP` chunk, not an ICC profile. HDR-aware viewers (current Chromium-based
+ browsers, for example) show it in HDR; **viewers that don't read `cICP` show the PQ values as if they were sRGB**,
+ so the picture looks flat and washed out there. That's how PQ PNG works, not a broken file: for a picture that
+ looks right everywhere, export a JPEG with HDR output on (an SDR image plus a gain map).
+
### Smart album rules
- The rule editor's field menu is grouped: Rating, Pick Flag, Color Label and Any Searchable Text at the top, then
submenus for Source, File, Date, Keywords & People, Description, Camera Info, Location, Size, Develop and Assisted