• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Saving as PNG with embedded Color Profile problem

Advocate ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

I did place this in the scripting section, because at the end of the day, I need it as part of an Applescript.

We do some processing, using Photoshop CC 2018. One part of the processing is writing out the file as .PNG. That file does need its Color Profile (sRGB) embedded.

I tried various possibilities, such as DOM Javascript, or Javascript with Action Codes (based on ScriptListener output).

Even if we set the profile to be embedded, the resulting PNG does not have it embedded.

One way which did work, however, was export for web. However, this option is in our case not usable, because it takes way too long.

Doing the same save as… in Photoshop CC 2017 gives the expected results.

So, question 1: Does anyone else encounter this problem, and question 2: is there a workaround, and question 3: as it looks like a bug, when will that bug be fixed?

Thanks a lot in advance for any advice.

Max Wyss.

TOPICS
Actions and scripting

Views

9.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advocate ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

Which code exactly do you use?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

Do you have such code in the AM version (from ScriptingListenerJS.log) ?.

var idEmbP = charIDToTypeID( "EmbP" );

desc.putBoolean( idEmbP, true );

//d.putBoolean(stringIDToTypeID("embedProfiles"), true);

//executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

function saveAsPngOmitProfile(file) {

    // Save as PNG built from Scripting Listener plugin.

    var idsave = charIDToTypeID( "save" );

    var desc1 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

    var desc2 = new ActionDescriptor();

    var idMthd = charIDToTypeID( "Mthd" );

    var idPNGMethod = stringIDToTypeID( "PNGMethod" );

    var idthorough = stringIDToTypeID( "thorough" );

    desc2.putEnumerated( idMthd, idPNGMethod, idthorough );

    var idPNGF = charIDToTypeID( "PNGF" );

    desc1.putObject( idAs, idPNGF, desc2 );

    var idIn = charIDToTypeID( "In  " );

    desc1.putPath( idIn, file ); // <------- 'file' is a File object passed.

    var idDocI = charIDToTypeID( "DocI" );

    desc1.putInteger( idDocI, 204 );

    var idLwCs = charIDToTypeID( "LwCs" );

    desc1.putBoolean( idLwCs, true );

    var idEmbP = charIDToTypeID( "EmbP" ); // <--------- HERE DISABLES EMBED PROFILE

    desc1.putBoolean( idEmbP, false );     // <--------- HERE DISABLES EMBED PROFILE

    executeAction( idsave, desc1, DialogModes.NO );

}

William Campbell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

This is presumably a bug, as embedding a color profile in PNG files had been possible for awhile. (A few/several years?) Before that the same bug prevailed: The PNG file was saved without an embedded profile, even if a profile was assigned to it. Adobe eventually acknowledged and fixed the bug. It appears that Adobe has "lost the recipe" again. How to test: Open any 24-bit image, choose File>Export>Save for Web (Legacy) and save as PNG-24 with "Convert to sRGB" enabled. When the resulting PNG file is opened in Photoshop, it does not have a color profile.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

Not sure it's a bug, more a change in thinking on Adobe's part. And the thing is, I agree -- there isn't a need for profiles in PNGs. My opinion of course, and this could be argued, perhaps for another topic. I say a change in thinking because it appears recent software updates have removed the option (in most cases, but not all, oddly) of the checkbox to include profile when saving as PNG. The reason I tend to agree with this thinking is PNG's primary use nowadays is for web. We can't rely on HTML viewers to recognize profiles and most consumer electronics assume sRGB, so it seems use sRGB and omit the profile makes sense. Technically PNG can store profiles, and the format can even store bitmap data, but that too isn't sensible to render on a webpage. And it's not like we use PNG for color-critical print work where profiles are essential.

At any rate, regardless of where one stands on if profiles should or should not appear in PNGs, this subject came to my attention because of a script I was writing to output various formats from Photoshop (https://www.marspremedia.com/software/photoshop/batch-multi-save). My choice for the script was to omit profiles in PNG.

Saving as described in my earlier post, I found it wasn't consistent, and hard to nail down why. It seems if a working profile is assigned, no matter the settings the PNG would get a profile included. This aspect could be a bug, I'm not sure. In the end, I went with Export Save For Web functionality of Photoshop scripting. It was the only solution that reliably omits the profile. Here is a section of the code I ended up with:

// folder is folder object, the destination folder.

// baseName is string the desired name of the file less extension.

var fileOut = new File(folder + "/" + File.encode(baseName) + ".png");

var exportOptions = new ExportOptionsSaveForWeb;

exportOptions.format = SaveDocumentType.PNG;

exportOptions.PNG8 = false; // For PNG-24; set true for PNG-8.

exportOptions.transparency = true;

exportOptions.includeProfile = false;

doc.exportDocument(fileOut, ExportType.SAVEFORWEB, exportOptions);

So far, this code has reliably omitted profiles from PNGs.

William Campbell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

It does appear that Adobe has decided that PNG files shouldn't have an embedded color profile. Depending on how you set up color management in Photoshop, opening a PNG image brings up a "Missing Profile" window that says the PNG image "has a file format that does not support embedded color profiles." Surprise! For the most part, I agree that PNG files are only needed in sRGB, but there can be exceptions, such as when a transparent background is needed with a higher quality color file (e.g., Adobe RGB). In fact, that just came up for me (which is why I am here), involving a logo going to a CAD/CAM system at a company that knows nothing about working with image file formats. However, given that Adobe has jettisoned profiles for PNG files, it would be nice if they could finish the job by saying that a PNG file is assumed to be sRGB. (And by modifying Save For Web to not show a check box for adding a profile to PNG files. Rather, it should say that there will be no profile, but the PNG will be prepared for sRGB. Or something like that. But...Adobe also calls Save For Web a "Legacy" function, which leads me to think that it's only going to get worse for users who need more control over preparation of PNG files.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

Well that thought is quite weird. why would you not add a profile, not adding it means bad representation on other screens. Also adding it as sRGB is almost a MUST in these days. 
We live in almost a display only world these days. sRGB isnt good on all displays, but it does make sure the recipient sees correct colors

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

I dont have this is with s4w, when i check convert to sRGB, it opens with that profile added

 

EDIT
i think i see what you mean, it also seems to auto convert to sRGB. While i dont understand what part does that, i looked at short string characters and done seem to find it. Im making a custom artboards and layercomps to files export script. I already found one which can do both at once, im adding ore functions and also fixing transparency in the PNF and TIFF methods. I also added option to conv to sRGB for all file formats. By reading this thread and testing i noticed that layer comps to files actually has this bug as well. It always saves as sRGB and always add color profile, even when you uncheck them. Also wonder why PNG is much longer, but thats probably s4w method, is sort of states that.

 

Ill check if i can find the option causing this

 

EDIT 2

Okay i got safe for web fogured out and also got the convert to sRGB working. The trick using this method is to flatten theimage before you do an export, thats mostly i guess why its slow. Without the dialog window save for web is quite fast.

You can test my update layercomps & artboards to files. See if it does help you. LINK

 

Layer comps & artboards to filesLayer comps & artboards to files

 

One thing i noticed using scriptlistener and checking quite some scripting pdf docs. In the save options, the boolean "convert to sRGB" seems missing. I prior added this using a function. But for save for web its integrated. By using the scriptlistener i noticed this part looks different than the regular Boolean options

 

this  is how i use it now together with add icc

 

 

// embed icc
var idEICC = charIDToTypeID( "EICC" );
desc4.putBoolean( idEICC, exportInfo.icc );
// Convert to sRGB
var idSWch = charIDToTypeID( "SWch" );
var idSTch = charIDToTypeID( "STch" );
if (exportInfo.convicc) {
var doConvert = charIDToTypeID( "CHsR" );
} else {
var doConvert = charIDToTypeID( "CHDc" );
}
desc4.putEnumerated( idSWch, idSTch, doConvert );

 

Most other Boolean options in tnat menu look like icc one. Took me a while to find this

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

This is clearly a bug, not intended behavior.

 

It was just recently brought to my attention that Save As PNG does indeed embed the profile correctly - as long as it's not sRGB! Any other profile embeds correctly. Only with sRGB is the checkbox grayed out and the profile stripped. It sounded so weird that I didn't believe it until I tried for myself.

 

Both Save For Web and Export embed all profiles correctly, so I always go that route when saving PNGs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 27, 2020 Jan 27, 2020

Copy link to clipboard

Copied

LATEST

I guess it just a missing optin, more save methods have this and also other applications have this.

 

I added it to my adjusted script and its fast. Doesnt really matter of you use s4w, as long there is no interface, its fast

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines