Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

PNG: write cHRM and gAMA when cICP can't describe the color space

Aperta
#5,558 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

The issue points to ColorConfig::get_chromaticities() and get_transfer_function_gamma() from #5521 and #5557, plus the PNG, DPX, RLA, and Targa writers; it does not name source files or tests. First read those property changes and inspect how the writers currently choose color metadata. Agree on the two proposed behaviors before implementing; done means the agreed metadata is written safely and the read-back limitations described here are accounted for.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Now that ColorConfig::get_chromaticities() and
get_transfer_function_gamma() exist (#5521, #5557), the PNG writer could use
them for color spaces its cICP chunk can't describe. Before writing the PR, I'd
like to agree on two behavior changes, because each changes what files carry
and how they read back.

What happens today. Writing a gray PNG from each of these color spaces with
OCIO's default config, and reading it back:

Written as The file carries Reads back as
lin_p3d65_scene, srgb_p3d65_scene cICP the same
lin_ap1_scene gAMA 1.0 lin_rec709_scene
g22_ap1_scene, g22_adobergb_scene nothing srgb_rec709_scene
lin_adobergb_scene, lin_ap0_scene nothing srgb_rec709_scene

So a file written from ACEScg reads back as linear Rec.709, and one written from
gamma 2.2 AdobeRGB as sRGB.

Proposal 1: PNG writes cHRM and gAMA when cICP can't describe the space.
When there is no cICP code and no ICC profile, the writer would take the
primaries from get_chromaticities() and a pure power from
get_transfer_function_gamma(), and write cHRM beside gAMA:

  • only together: primaries without a transfer function would be half a
    description, so a log or piecewise curve still gets no chunk;
  • not for Rec.709 primaries, where gAMA alone already says everything;
  • not for primaries cHRM can't store: it holds no negative or zero
    coordinate, so ACES AP0 (blue y is negative) is lost, with a debug message;
  • not for primaries the libPNG in use refuses. Older libPNG releases reject
    some valid ones, such as ACES AP1's red (x + y > 1), and that rejection
    aborts the write, so the writer would check them on a scratch structure
    first.

ACEScg, gamma 2.2 AP1, AdobeRGB and the other spaces above would then carry
their primaries, which browsers and image editors honor.

Proposal 2: writers tag any linear color space as gamma 1.0. Today the gamma
that PNG, DPX, RLA and Targa write is 1.0 only for lin_rec709_scene and names
equivalent to "linear" or "scene_linear". With get_transfer_function_gamma(),
any color space with a linear transfer function would get 1.0, so linear
AdobeRGB or ACES2065-1 would no longer write no gamma at all.

The catch: reading back. OpenImageIO's PNG reader ignores cHRM today, so
these files would still read back with Rec.709 primaries in OpenImageIO, now
with the right transfer function. #5516 proposes reading cHRM and gAMA as
metadata. DPX, RLA and Targa have no field for primaries, so a linear ACEScg
DPX would read back as linear Rec.709 (as a linear ACEScg PNG already does).

Questions

  1. Should PNG write cHRM before OpenImageIO's own reader reads it? Other
    readers would interpret these files correctly right away.
  2. Is gamma 1.0 with unstated primaries better than no gamma for linear color
    spaces in DPX, RLA and Targa?

These would be the first in-tree users of the properties #5521 added.

Assisted-by: Claude Code / Claude Opus 5.5

Lingua principale
C++
Stelle
2.4k
Fork
716
Merge medio
2g 9h
PR unite (30g)
91

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AcademySoftwareFoundation/OpenImageIO

Tutte le issue di AcademySoftwareFoundation/OpenImageIO

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.