ACEScg: File Handling option opens colour-less EXR renders in the ACES working space (#4908)

* ACEScg: File Handling option opens colour-less EXR renders in the ACES working space

Our render pipelines write ACEScg (AP1 primaries, ACES white ~D60,
linear) and — like most — state no colour space in the EXR header, so
io's linear-sRGB default misrepresented them (saturated hues shifted).
- cms: AcesCg joins the built-in profiles, generated from the published
  AP1 primaries and ACES white point with a linear TRC (id "aces-cg",
  aliases acescg).
- engine: File Handling gets "Open color-less EXR as ACEScg". When on,
  an EXR that io tagged with the linear-sRGB default opens as ACEScg
  instead; embedded or EXIF-declared profiles stay untouched.
Translated in every catalog. ACES view transforms (OCIO-based display)
remain future work; this covers the document's source colours.

* scorecard: 26 of 158 (main's #3472 preference added one too)

* Regenerate docs/scorecard.md after merging main

---------

Co-authored-by: Brandon Thomas <[email protected]>
This commit is contained in:
Elvis33LEandBrandon Thomas authored and GitHub committed 2026-10-14 13:46:27 -04:00
1 parent a3a47e9cb0
commit aa44eafe2c
25 files changed
+93 -5

No files matched your search

+13 -3
View File
@@ -26,6 +26,8 @@ pub enum Builtin {
ProPhotoCompat,
/// sRGB primaries with a linear transfer function.
LinearSrgb,
/// ACEScg: AP1 primaries, the ACES white point (~D60), linear transfer. The ACES working space for CG renders.
AcesCg,
/// Rec. 2020 primaries, D65, Rec. 709 transfer function.
Rec2020,
/// Gray, gamma 2.2.
@@ -43,12 +45,13 @@ pub enum Builtin {
}
impl Builtin {
pub const ALL: [Builtin; 11] = [
pub const ALL: [Builtin; 12] = [
Builtin::Srgb,
Builtin::DisplayP3,
Builtin::AdobeRgbCompat,
Builtin::ProPhotoCompat,
Builtin::LinearSrgb,
Builtin::AcesCg,
Builtin::Rec2020,
Builtin::GrayGamma22,
Builtin::SGray,
@@ -65,6 +68,7 @@ impl Builtin {
Builtin::AdobeRgbCompat => "adobe-rgb-compat",
Builtin::ProPhotoCompat => "prophoto-compat",
Builtin::LinearSrgb => "linear-srgb",
Builtin::AcesCg => "aces-cg",
Builtin::Rec2020 => "rec2020",
Builtin::GrayGamma22 => "gray-gamma-2.2",
Builtin::SGray => "sgray",
@@ -82,6 +86,7 @@ impl Builtin {
Builtin::AdobeRgbCompat => "Adobe RGB (1998)-compatible (Photocraft)",
Builtin::ProPhotoCompat => "ProPhoto RGB-compatible (ROMM primaries, Photocraft)",
Builtin::LinearSrgb => "Linear sRGB (Photocraft)",
Builtin::AcesCg => "ACEScg (AP1, linear, Photocraft)",
Builtin::Rec2020 => "Rec. ITU-R BT.2020 (Photocraft)",
Builtin::GrayGamma22 => "Gray Gamma 2.2 (Photocraft)",
Builtin::SGray => "sGray (sRGB tone curve, Photocraft)",
@@ -104,6 +109,7 @@ impl Builtin {
"gray" | "graygamma22" | "gamma22" => Some(Builtin::GrayGamma22),
"sgray" | "graysrgb" => Some(Builtin::SGray),
"dotgain20" | "dotgain20compat" | "dotgain" => Some(Builtin::DotGain20Compat),
"aces-cg" | "acescg" => Some(Builtin::AcesCg),
"lab" | "labd50" | "cielab" => Some(Builtin::LabD50),
"cmyk" | "coatedcmyk" | "defaultcmyk" | "photocraftcoatedcmyk" => Some(Builtin::CoatedCmyk),
_ => None,
@@ -113,7 +119,7 @@ impl Builtin {
/// The profile (built once per process).
pub fn profile(self) -> &'static Profile {
static CELLS: [OnceLock<Profile>; 11] = [const { OnceLock::new() }; 11];
static CELLS: [OnceLock<Profile>; 12] = [const { OnceLock::new() }; 12];
// `ALL` lists the variants in declaration order (checked by `all_in_declaration_order`),
// so the discriminant is the cell index.
CELLS[self as usize].get_or_init(|| build(self))
@@ -256,12 +262,13 @@ fn lab() -> Profile {
pub const COATED_CMYK_ICC: &[u8] = include_bytes!("../profiles/photocraft-coated-cmyk.icc");
fn build(b: Builtin) -> Profile {
let (srgb_p, p3, adobe, romm, bt2020) = (
let (srgb_p, p3, adobe, romm, bt2020, ap1) = (
[[0.64, 0.33], [0.30, 0.60], [0.15, 0.06]],
[[0.680, 0.320], [0.265, 0.690], [0.150, 0.060]],
[[0.64, 0.33], [0.21, 0.71], [0.15, 0.06]],
[[0.7347, 0.2653], [0.1596, 0.8404], [0.0366, 0.0001]],
[[0.708, 0.292], [0.170, 0.797], [0.131, 0.046]],
[[0.713, 0.293], [0.165, 0.830], [0.128, 0.044]],
);
match b {
Builtin::Srgb => rgb(b.description(), srgb_p, d65(), srgb_trc()),
@@ -269,6 +276,9 @@ fn build(b: Builtin) -> Profile {
Builtin::AdobeRgbCompat => rgb(b.description(), adobe, d65(), Curve::Gamma(563.0 / 256.0)),
Builtin::ProPhotoCompat => rgb(b.description(), romm, math::D50, Curve::Gamma(1.8)),
Builtin::LinearSrgb => rgb(b.description(), srgb_p, d65(), Curve::Gamma(1.0)),
// ACEScg is scene-linear on the AP1 primaries with the ACES white point (~D60,
// xy 0.32168/0.33767, the ACES 2065-1 neutral).
Builtin::AcesCg => rgb(b.description(), ap1, math::xy_to_xyz([0.32168, 0.33767]), Curve::Gamma(1.0)),
Builtin::Rec2020 => {
// Rec. 709 OETF inverse: V = 1.099 L^0.45 − 0.099 (L ≥ 0.018), 4.5 L below.
let a = 1.099;
+53
View File
@@ -457,6 +457,20 @@ fn save_a_copy(s: &mut Session, p: &Value) -> Result<Value> {
}
/// Open a file's bytes, decoding them as the format `as_ext` (Open As) when given.
/// EXR/HDR rarely states its colour space, so io tags it with the linear-sRGB default.
/// With File Handling's ACEScg option on, such an EXR opens as ACEScg instead (AP1,
/// linear) — the working space ACES render pipelines write. Only the io default is
/// replaced; an embedded or EXIF-declared profile is kept untouched.
fn tag_exr_colorspace(s: &Session, name: &str, doc: &mut Document) {
if !name.to_ascii_lowercase().ends_with(".exr") || !s.prefs.get().file_handling.exr_aces_cg {
return;
}
let linear = photocraft_cms::Builtin::LinearSrgb.profile().to_bytes();
if doc.icc_profile.as_ref().map(|v| v.as_slice()) == Some(linear.as_slice()) {
doc.icc_profile = Some(photocraft_cms::Builtin::AcesCg.profile().to_bytes());
}
}
pub fn open_bytes_as(s: &mut Session, name: &str, bytes: &[u8], as_ext: Option<&str>, path: Option<String>) -> Result<Value> {
crate::allocation::checkpoint("importing document")?;
let decode_name = match as_ext {
@@ -465,6 +479,7 @@ pub fn open_bytes_as(s: &mut Session, name: &str, bytes: &[u8], as_ext: Option<&
};
let r = photocraft_io::import(&decode_name, bytes).map_err(|e| EngineError::Other(format!("{decode_name}: {e}")))?;
let mut doc = r.document;
tag_exr_colorspace(s, &decode_name, &mut doc);
let path = match template_name(s, name) {
Some(untitled) => {
doc.name = untitled;
@@ -1616,3 +1631,41 @@ pub fn specs() -> Vec<CommandSpec> {
#[cfg(test)]
#[path = "file_cmds/tests.rs"]
mod tests;
#[cfg(test)]
mod aces_exr_tests {
use super::*;
/// File Handling › "Open color-less EXR as ACEScg": off, an EXR opens on io's linear-sRGB
/// default; on, it opens as ACEScg — the working space ACES render pipelines write.
#[test]
fn exr_aces_cg_preference_retags_the_opened_document() {
let image = photocraft_codecs::Image::from_f32(
4,
4,
photocraft_codecs::ChannelLayout::Rgb,
&[
0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5,
0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0, 0.25, 0.5, 0.75, 1.0,
],
)
.unwrap();
let bytes = photocraft_codecs::encode(&image, photocraft_codecs::Format::OpenExr, &photocraft_codecs::EncodeOptions::default()).unwrap();
let linear = photocraft_cms::Builtin::LinearSrgb.profile().to_bytes();
let aces = photocraft_cms::Builtin::AcesCg.profile().to_bytes();
// Off (the default): io's linear-sRGB tagging stays.
let mut s = Session::new();
open_bytes_as(&mut s, "shot.exr", &bytes, None, None).unwrap();
let d = &s.active().unwrap().doc;
assert_eq!(d.icc_profile.as_deref().map(|v| v.as_slice()), Some(linear.as_slice()));
// On: the same file opens as ACEScg.
let mut s = Session::new();
s.prefs.edit(|p| p.file_handling.exr_aces_cg = true);
open_bytes_as(&mut s, "shot.exr", &bytes, None, None).unwrap();
let d = &s.active().unwrap().doc;
assert_eq!(d.icc_profile.as_deref().map(|v| v.as_slice()), Some(aces.as_slice()));
}
}
+4
View File
@@ -525,6 +525,9 @@ pub struct FileHandling {
pub recover_on_launch: bool,
/// Open a file with no ICC profile as untagged even when its EXIF ColorSpace tag says sRGB.
pub ignore_exif_profile_tag: bool,
/// Most renderers write ACEScg EXRs without stating the colour space. With this on, an EXR
/// that would otherwise open as linear sRGB opens as ACEScg (AP1, linear) instead.
pub exr_aces_cg: bool,
pub ask_before_saving_layered_tiff: bool,
pub maximize_psd_compatibility: Ask,
/// SVG groups deeper than this are rasterised on import; parser and document safety caps remain fixed.
@@ -544,6 +547,7 @@ impl Default for FileHandling {
autosave_minutes: 10,
recover_on_launch: true,
ignore_exif_profile_tag: false,
exr_aces_cg: false,
ask_before_saving_layered_tiff: true,
maximize_psd_compatibility: Ask::Always,
rasterize_svg_groups_deeper_than: photocraft_doc::MAX_GROUP_DEPTH as u32,
+1
View File
@@ -3753,3 +3753,4 @@ navigator Zoom Zvětšení
Sent to {printer} Odesláno do {printer}
set in Print Settings… nastavuje se v nastavení tisku…
ICO is limited to 256 × 256 pixels ICO je omezen na 256 × 256 pixelů
Open color-less EXR as ACEScg Otevřít EXR bez údaje o barevném prostoru jako ACEScg
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3143,3 +3143,4 @@ curves Smooth Glätten
Sent to {printer} An {printer} gesendet
set in Print Settings… in den Druckeinstellungen festlegen…
ICO is limited to 256 × 256 pixels ICO ist auf 256 × 256 Pixel begrenzt
Open color-less EXR as ACEScg Farbangabenloses EXR als ACEScg öffnen
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3843,3 +3843,4 @@ curves Smooth Εξομάλυνση
Sent to {printer} Στάλθηκε στον {printer}
set in Print Settings… ορίζεται στις ρυθμίσεις εκτύπωσης…
ICO is limited to 256 × 256 pixels Το ICO περιορίζεται σε 256 × 256 εικονοστοιχεία
Open color-less EXR as ACEScg Άνοιγμα EXR χωρίς χρωματική δήλωση ως ACEScg
Can't render this file because it contains an unexpected character in line 1029 and column 18.
+1
View File
@@ -2830,3 +2830,4 @@ curves Smooth Suavizar
Sent to {printer} Enviado a {printer}
set in Print Settings… se establece en Ajustes de impresión…
ICO is limited to 256 × 256 pixels ICO está limitado a 256 × 256 píxeles
Open color-less EXR as ACEScg Abrir EXR sin espacio de color como ACEScg
Can't render this file because it contains an unexpected character in line 4 and column 47.
+1
View File
@@ -3147,3 +3147,4 @@ curves Smooth Lisser
Sent to {printer} Envoyé à {printer}
set in Print Settings… défini dans les paramètres d’impression…
ICO is limited to 256 × 256 pixels Le format ICO est limité à 256 × 256 pixels
Open color-less EXR as ACEScg Ouvrir les EXR sans espace colorimétrique en ACEScg
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -4066,3 +4066,4 @@ cameraRaw Yellow Sárga
Ink Characteristics Festék jellemzői
Solidity: Fedőképesség:
Redrawing Újrarajzolás
Open color-less EXR as ACEScg Színinformáció nélküli EXR megnyitása ACEScg-ként
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3134,3 +3134,4 @@ curves Smooth Haluskan
Sent to {printer} Dikirim ke {printer}
set in Print Settings… diatur di Pengaturan Cetak…
ICO is limited to 256 × 256 pixels ICO dibatasi hingga 256 × 256 piksel
Open color-less EXR as ACEScg Buka EXR tanpa informasi warna sebagai ACEScg
Can't render this file because it contains an unexpected character in line 4 and column 47.
+1
View File
@@ -4108,6 +4108,7 @@ navigator Zoom Zoom
Sent to {printer} Inviato a {printer}
set in Print Settings… impostato nelle impostazioni di stampa…
ICO is limited to 256 × 256 pixels ICO è limitato a 256 × 256 pixel
Open color-less EXR as ACEScg Apri gli EXR senza spazio colore come ACEScg
# Color management, Liquify, glyph group, warp and Camera Raw labels the Serbian, Vietnamese and Japanese catalogs added
Adobe-rgb-compat Adobe RGB (compatibile)
Can't render this file because it contains an unexpected character in line 2647 and column 53.
+1
View File
@@ -3822,3 +3822,4 @@ curves Smooth スムーズ
Reset All Locked Settings ロックされた設定をすべて初期化
Copy Texture to Other Tools テクスチャを他のツールにコピー
ICO is limited to 256 × 256 pixels ICO は 256 × 256 ピクセルまでです
Open color-less EXR as ACEScg 色空間のないEXRをACEScgとして開く
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3320,3 +3320,4 @@ curves Smooth 매끄럽게
Sent to {printer} {printer}(으)로 전송됨
set in Print Settings… 인쇄 설정에서 지정…
ICO is limited to 256 × 256 pixels ICO는 256 × 256픽셀로 제한됩니다
Open color-less EXR as ACEScg 색 공간 정보 없는 EXR을 ACEScg로 열기
Can't render this file because it contains an unexpected character in line 3160 and column 53.
+1
View File
@@ -3905,3 +3905,4 @@ curves Smooth Vloeiend maken
Sent to {printer} Verzonden naar {printer}
set in Print Settings… instellen in de afdrukinstellingen…
ICO is limited to 256 × 256 pixels ICO is beperkt tot 256 × 256 pixels
Open color-less EXR as ACEScg EXR zonder kleurruimte als ACEScg openen
Can't render this file because it contains an unexpected character in line 8 and column 34.
+1
View File
@@ -3743,3 +3743,4 @@ curves Smooth Wygładź
Sent to {printer} Wysłano do {printer}
set in Print Settings… ustawiane w ustawieniach druku…
ICO is limited to 256 × 256 pixels ICO jest ograniczony do 256 × 256 pikseli
Open color-less EXR as ACEScg Otwieraj EXR bez profilu koloru jako ACEScg
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3935,3 +3935,4 @@ layerLabel No Color Sem cor
Sent to {printer} Enviado para {printer}
set in Print Settings… definido nas configurações de impressão…
ICO is limited to 256 × 256 pixels ICO é limitado a 256 × 256 pixels
Open color-less EXR as ACEScg Abrir EXR sem espaço de cor como ACEScg
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3111,3 +3111,4 @@ curves Smooth Сгладить
Gray Value (Median) Уровень серого (медиана)
Integrated Density Интегральная плотность
Length Длина
Open color-less EXR as ACEScg Открывать EXR без цветового профиля как ACEScg
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -4219,4 +4219,5 @@ shape Appearance Izgled
Ink Characteristics Karakteristike mastila
Solidity: Punoća:
Redrawing Ponovno iscrtavanje
Open color-less EXR as ACEScg Otvori EXR bez podatka o bojama kao ACEScg
Show home recent files Prikaži nedavne datoteke na početnom ekranu
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -3877,3 +3877,4 @@ cameraData Lens Lens
Ink Characteristics Mürekkep Özellikleri
Solidity: Doluluk:
Redrawing Yeniden çiziliyor
Open color-less EXR as ACEScg Renk bilgisi olmayan EXR'yi ACEScg olarak aç
Can't render this file because it contains an unexpected character in line 8 and column 34.
+1
View File
@@ -3844,3 +3844,4 @@ curves Smooth Згладити
Sent to {printer} Надіслано на {printer}
set in Print Settings… задається в параметрах друку…
ICO is limited to 256 × 256 pixels ICO обмежено розміром 256 × 256 пікселів
Open color-less EXR as ACEScg Відкривати EXR без колірного профілю як ACEScg
Can't render this file because it contains an unexpected character in line 1387 and column 18.
+1
View File
@@ -3632,3 +3632,4 @@ curves Smooth Làm mượt
Sent to {printer} Đã gửi tới {printer}
set in Print Settings… đặt trong thiết lập in…
ICO is limited to 256 × 256 pixels ICO giới hạn ở 256 × 256 pixel
Open color-less EXR as ACEScg Mở EXR không khai báo màu sắc dưới dạng ACEScg
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -2755,3 +2755,4 @@ curves Smooth 平滑
Sent to {printer} 已发送到 {printer}
set in Print Settings… 在打印设置中设置…
ICO is limited to 256 × 256 pixels ICO 最大为 256 × 256 像素
Open color-less EXR as ACEScg 将无色彩空间信息的 EXR 以 ACEScg 打开
Can't render this file because it contains an unexpected character in line 2593 and column 53.
+1
View File
@@ -2740,3 +2740,4 @@ curves Smooth 平滑
Sent to {printer} 已傳送至 {printer}
set in Print Settings… 在列印設定中設定…
ICO is limited to 256 × 256 pixels ICO 最大為 256 × 256 像素
Open color-less EXR as ACEScg 將無色彩空間資訊的 EXR 以 ACEScg 開啟
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -1024,6 +1024,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
fn humanize(key: &str) -> String {
match key {
"appearanceMode" => return "Appearance Mode".into(),
"exrAcesCg" => return "Open color-less EXR as ACEScg".into(),
"darkTheme" => return "Dark Theme".into(),
"lightTheme" => return "Light Theme".into(),
_ => {}
+2 -2
View File
@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |
| [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 147/256, round trip ≥ 258/256 |
| [Tools](#tools) | 29 | 13 | 1 | |
| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 158 (target 0) |
| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 159 (target 0) |
| [Type](#type) | 4 | 3 | 2 | |
| [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) |
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |
@@ -176,7 +176,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
## Workspace and UI
**Settings that do nothing: 26 of 158** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
**Settings that do nothing: 26 of 159** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.