Skip to main content
Known Participant
October 22, 2017
Question

PNG support for colour profiles incomplete/unpredictable in CC 2018

  • October 22, 2017
  • 8 replies
  • 6121 views

Hello,

The new Export As... Embed profile checkbox doesn’t work properly with PNG8 files (“Smaller Files”). Mac and Windows edition of CC 2018 behaves differently when it comes to recognising sRGB chunk in PNG files (incl. those saved from Photoshop). The new CC 2018 PNG support through Save As.. has lost an ability to embed colour profiles (it works correctly in CC 2017).

For a detailed report, please see: PNG8 colour support broken · Issue #392 · adobe-photoshop/generator-core · GitHub

Regards

m.

    This topic has been closed for replies.

    8 replies

    Inspiring
    March 13, 2022

    "pow(1/2.2) curve meant to indicate sRGB" sRGB IS NOT 2.2 GAMMA. Why so many people do such a mistake? the code you mentioned is just giving fallback values for gAMA chunk, 2.2 is mandated in png spec for sRGB chunk. Only when sRGB chunk is present you are using it, that is for old apps.

    Inspiring
    March 13, 2022

    "That's news to me, since I worked at Apple and Adobe and EA.  The gpu samplers support sRGB (althought Xbox 360 had a piecewise linear sRGB curve).   The color-space conversion is all shader-based, and sometimes sampler based for some formats.  So yes, there's extended sRGB, and a few other formats that one can access, but the lowest-common denominator and publicly accessible formats are for BC1 and BC1_srgb"

     

    LOL, i did not mean using bare OpenCL/GL/Vulkan, but this as part of skia: https://skia-review.googlesource.com/c/skcms/+/388596/21

     

    Last time I checked it is run on GPU. This is skcms, that works like Little CMS using all kind of GPGPU, shaders (HLSL) and other stuff. No insanely complex CMYK support yet.

    Inspiring
    March 13, 2022

    "The spec says to honor ICCP, and fallback to Gama, Chrm, and others.  Srgb is also exclusive of ICCP.   But I still don't know what to parse out of the iccp profile to identify sRGB.  Do i have to compare 9 float values of seperate r/g/b matrices.   Ugh.  The srgb icc color profiles from the icc website that I downloaded are each 64K, and so I assume Apple and Adobe are leaving out giant chunks to get these down to 3K.  And yes, I'm ignoring that these might be default compressed. "

    The spec only says to fallback for old applications. All new applications must use sRGB with linear part for sRGB chunk and sRGB variant (that is never a pure sRGB, since how ICC spec is done) in iCCP chunk, not pure 2.2 gamma, *that* is what gAMA chunk is. I just recommend using Little CMS that is what GIMP does. I think it is better anyway than Adobe CMS, unless when on Apple and thus using Apple CMS.

    Participating Frequently
    March 10, 2022

    In the year 2022AD, Photoshop still can't seem to write out or read a PNG sRGB chunk.  Apple Preview then takes these images, and displays them as non-SRGB data.   Considering that most of the content that we're designing is in srgb8 space, this basically means ignoring any sRGB chunk since Photoshop will never write it out, and overriding it by identifying the image as an albedo map (srgb), normal map (non-srgb), or other map in games.   Why has Photoshop had PNG export without this for it's lifespan?  And embedding 3K iCCP profiles to indicate sRGB isn't cool either in the deprecated "Save for Web".   

     

    D Fosse
    Community Expert
    Community Expert
    March 11, 2022
    quote

    embedding 3K iCCP profiles to indicate sRGB isn't cool either in the deprecated "Save for Web".   

     

    By @defaultp677vp74sy2q

     

    So you don't want to embed the sRGB profile, but still expect other applications to treat it as sRGB? I don't see how this is a Photoshop problem. It's treated as sRGB if the profile is embedded and the application is color managed.

     

    Policies for untagged images vary between applications. Web browsers will automatically assign sRGB, but most other applications will just pass the RGB numbers straight through to screen.

    Participating Frequently
    March 11, 2022

    Web browsers break with sRGB, gama, chrm, or iccp embedded in them.  They try to convert and store the data in linear space.  That means to use the browser loaders that go to native C++ libraries, the blocks must all be stripped, and the srgb state passed separately.  So it still needs to be there, but that doesn't mean it's handled consistently.

     

    I finally updated from PS2021 to PS2022 and "Save As" finally has and option to save a srgb profile but it's a gama and iccp block.  There are about a million different iccp blocks, some from Apple. Some from Adobe, and other image programs.  There is one sRGB block and it's a simple Boolean to check in png loaders.  What is the code to test iccp blocks across all vendors?

     

    My point about not having sRGB is about all of our files saved by artists still using PS2021 and older.  That's why I have to ignore the setting, but Apple a preview doesn't.   None of these files have sRGB written or read, so we have to supplement that data when processing the images.  Also Photoshop has no ktx or ktx2 export which is ultimately what we generate for games.

    Inspiring
    October 29, 2021

    GIMP now supports gAMA chunk!

    NB, colourmanagement
    Community Expert
    Community Expert
    October 28, 2021

    Witcasy

     

             "ICC profile support is as important for indexed colour as for any other image mode."

    totally agree - since continuity of colour appearance relies entirely on embedded profiles (yeah, ideally small ones, especially for web) it seems ridiculous that ANY image format is unable to support them in Adobe apps.

     


    neil barstow, colourmanagement net :: adobe forum volunteer
    google me "neil barstow colourmanagement" for lots of free articles on colour management
    [please only use the blue reply button at the top of the page, this maintains the original thread title and chronological order of posts]

    D Fosse
    Community Expert
    Community Expert
    January 15, 2021

    A few things to clear up in this old thread from 2017, as some of the things I wrote back then aren't correct. Or not correct anymore, they may have changed.

     

    PNG icc profile support is indeed very inconsistent in Photoshop, and I'm sure a lot of it qualifies as bugs.

    • Save As PNG will not embed the profile if that profile happens to be sRGB. Which is of course the profile you need in almost all cases. All other profiles are correctly embedded.
    • Export and Save For Web both embed profiles correctly. However, the "embed profile" checkbox is not only off by default - but in Export it doesn't even stick when you check it. You have to do it every time (!).

     

    As for web browsers, there's been some significant changes. The most important one is that Microsoft Edge now has full color management, and it has also adopted the policy of assigning sRGB to untagged material, not only images, but all page elements. This means all major web browsers should now display everything correctly, with full color management everywhere. The only browser lagging a little behind is Firefox, where you still have to manually enable the "assign sRGB" function (mode 1).

     

    This also means that for web, embedding the profile is no longer strictly necessary. However, most standard image viewers still require a profile, if they support color management at all. Considering that an sRGB profile is only 3kB, there is absolutely no reason to not embed. It's still the only way to maximize the chances of correct representation.

     

    The original question was about 8-bit indexed PNGs. Whether icc profile support is technically possible with indexed color is moot and beside the point. It simply makes no sense, and if accurate color is a consideration you don't use indexed color.

    Inspiring
    January 15, 2021

    For web the standard mandates that images without iCCP (icc) or gAMA chunks (gamma) (for png) or sRGB chunk and others are parsed as sRGB. That is mandatory, firefox is breaking the standrd here, there is a bug in firefox and you can activate about:config to 1. Anyway, GIMP also does not support gAMA chunk, there is an open bug there too.

     

    For other apps, it is technically should be like that too, no standard exist, of course.

    witkacyAuthor
    Known Participant
    October 22, 2017

    Hi,

    if you're concerned with color accuracy, you wouldn't use indexed color in the first place

    I respectfully disagree. PNG8 is still the only (sane) way to support images with transparency in some popular browsers (it doesn’t help that Photoshop doesn’t natively support JXR, WebP and only partly supports JP2). Why these images have to suffer unpredictable saturation shifts by being misinterpreted as being in display device’s space because of the lack of colour information?

    an indexed PNG can be safely assumed to be intended for an sRGB environment

    Yeah, that’s what the web specs say for years (about untagged imagery in general). Unfortunately browsers (and other applications/OSes) do not correctly assume sRGB for untagged images (situation is changing for the better as we speak, but still). Why would Photoshop want to add to that confusion? Again: even if that’s a (wrong) concious decision, UI suggests differently and is misleading.

    In photoshop cc 2018 have you tried File>Export>Save for Web?

    Thanks, Jeff. Save for Web has it’s own set quirks when it comes to colour profiles :-). But, crucially, its support for PNG8 is miserable compared to Export As... (only 1-bit transparency allowed).

    I just thought it may be a good time to get engineer’s attention, which I’ve tried using different channels for a while now, as the PNG code was definitely touched in CC 2018 and better support for PNG is being advertised ;-).

    Maybe it would be prudent to make Photoshop correctly recognise sRGB PNG chunks and then always use those when writing PNGs in sRGB colour space instead of unnecessarily weighty iCCP chunks, too (2,6KB extra)? For the files to be smaller, but also to avoid long-standing issues like Original sRGB profile is not correctly recognised as such by IM/libpng (culprit: pngcrush code to deal with it​?). But here, I’m a newbie and this is way above my understanding...

    Regards

    m.

    D Fosse
    Community Expert
    Community Expert
    October 22, 2017

    Unfortunately browsers (and other applications/OSes) do not correctly assume sRGB for untagged images\

    Firefox has done that for many years (with the mode 1 setting), and I hear Chrome and Opera do it too now. On Mac, Safari has to do it, ever since Apple started fitting the iMacs and MBPs with wide gamut displays.

    So that basically just leaves Edge/IE - but Microsoft's browsers have always been known for their lacking color management support. Nothing new there.

    The OS isn't supposed to assume anything. This is called by the application, not the OS - it's just supposed to make the profiles available when the application requests it.

    witkacyAuthor
    Known Participant
    October 22, 2017

    Hi,

    Thanks for the answer.

    PNG-8 is indexed color, which doesn't support icc profiles.

    Colour profiles are supported for all PNG types (indexed included): PNG Specification: Chunk Specifications​. As is sRGB chunk. Plenty of indexed PNGs in the wild with both and support for it in other applications. Even if Adobe would choose not to follow PNG spec and wide practice and add to confused colour all over the web by not supporting iCCP and sRGB chunks for indexed PNGs, they would need to disable checkboxes that currently aren’t working as advertised and are confusing.

    Save As PNG (...) embed the profile correctly

    Apologies. You’re right, I was mislead by unchecked AND greyed out Embed profile checkbox in Save As for images in sRGB. Profiles are correctly saved provided they are NOT sRGB. However, if the image is in sRGB, Photoshop CC2018 Win doesn’t write sRGB  or iCCP chunks (Export As PNG-24 saves iCCP, it could produce smaller files by using sRGB chunk, but at least it doesn’t produce incorrect files).

    In other words, there's nothing wrong. Everything is as expected.

    Not my experience, unfortunately. Also Mac and Windows versions are incompatible now (in CC 2018) when it comes to recognising sRGB chunks in files (incl. those they wrote themselves), amazingly – both are wrong (Win doesn’t recognise sRGB chunks, Mac sees them in PNGs without sRGB chunks).

    Plenty to improve, I would say.

    Coming back to colour profiles in indexed PNGs. I’ve used the spec argument above just to reinforce my point. But, to be honest, I don’t care for the spec as such. Imagine an indexed PNG with just one, red colour. Wouldn’t you want to know if that red is in sRGB or ProPhotoRGB?!

    Regards

    m.

    D Fosse
    Community Expert
    Community Expert
    October 22, 2017

    Colour profiles are supported for all PNG types (indexed included)

    Well, maybe, I don't know. But if you're concerned with color accuracy, you wouldn't use indexed color in the first place. And vice versa.

    Imagine an indexed PNG with just one, red colour. Wouldn’t you want to know if that red is in sRGB or ProPhotoRGB?!

    Again, maybe. Same argument as hex color: an indexed PNG can be safely assumed to be intended for an sRGB environment.

    D Fosse
    Community Expert
    Community Expert
    October 22, 2017

    PNG-8 is indexed color, which doesn't support icc profiles.

    Export As PNG-24, as well as Save As PNG, both embed the profile correctly. Just tested in Win 10.

    In other words, there's nothing wrong. Everything is as expected.