Changing Color profile through script

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

dansaDisco

Changing Color profile through script

Post by dansaDisco »

Hey guys!

I really hope somebody can help me with this, because I've been googling for hours without getting anything from it >_<

I have a quite simple, but annoying issue. I'm using a program for osX that converts apples crunched .png files into readable ones so that I can edit them in photoshop.
There is only one issue with this program, it swaps the red and blue channels..
So instead of giving me regular sRGB pngs, i get sBGR... I hope you can see the problem here

I have made a action to that makes the process of applying the regular sRGB profile easier.
BUT, then i learned about Photoshop Scripts when installing a script that saved all .psd's in a folder to .png's (very handy!)

And I started to think, perhaps I could add a line to this code that also converts the file into sRGB if it's not, so I started digging my way through the internetz! But I found nothing. So Hopefully you can help me here.

The script I would like to alter is this:

Code: Select all#target photoshop
var imageFolder = Folder.selectDialog("Select top folder to process");
var folderList=[];
if (imageFolder != null)  {
 processFolder(imageFolder);
 folderList.unshift(imageFolder);
 createPNGfromPDF(folderList);
}
function createPNGfromPDF(folderList){
 for(var a in folderList){
  var fileList = folderList[a].getFiles ("*.psd");
   for (var z in fileList){
    var file = fileList[z];
    open(file);
    var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
    var saveFile = File(decodeURI(fileList[z].path+"/"+Name+".png"));
    SavePNG(saveFile);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
  }
}
function processFolder(folder) {
    var fileList = folder.getFiles()
     for (var i = 0; i < fileList.length; i++) {
        var file = fileList;
if (file instanceof Folder) {
  folderList.push(file); 
       processFolder(file);
    }
   }
}
function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();
    pngSaveOptions.embedColorProfile = true;
    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    pngSaveOptions.matte = MatteType.NONE;
    pngSaveOptions.quality = 1;
 pngSaveOptions.PNG8 = false;
    pngSaveOptions.transparency = true;
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}