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

Color profile script

Guest
May 08, 2011 May 08, 2011

Copy link to clipboard

Copied

Is it possible to create a script that goes through a folder, and changes every .png file to use sRGB as color profile?

Edit:

To further describe my problem- I use a application that decrypt apples .png files so that they can be read in photoshop. But for some reason this script flips the blue and red channels too, making the colors messed up when i save a file.

So basically, i need a script that opens every png file, and converts their color profile from sBGR to sRGB and then saves them.

I already have a script that can convert PSD's to PNG's, but it does not edit the color profile, so if it could be edited to do that (And possibly also edit .png files) that would be awesome. the script:

#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.getFiles ("*.psd");

   for (var z in fileList){

    var file = fileList;

    open(file);

    var Name = fileList.name.replace(/\.[^\.]+$/, '');

    var saveFile = File(decodeURI(fileList.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);

}

TOPICS
Actions and scripting

Views

3.3K
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
Community Expert ,
May 08, 2011 May 08, 2011

Copy link to clipboard

Copied

convertProfile (destinationProfile, intent [, blackPointCompensation] [, dither])

JJMack

Votes

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
Guest
May 08, 2011 May 08, 2011

Copy link to clipboard

Copied

Could you elaborate? Where should i put this line, do i have to use any variables?

Remember, I'm not familiar with Photoshop Scripts at all..

Votes

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 ,
May 09, 2011 May 09, 2011

Copy link to clipboard

Copied

Votes

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
Guest
May 10, 2011 May 10, 2011

Copy link to clipboard

Copied

Alright, thanks! though there's just one thing I'd need help with..

Would i need to edit the line of code you posted? and if so.. Well, how?

convertProfile (destinationProfile, intent [, blackPointCompensation] [, dither])

Votes

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 ,
May 11, 2011 May 11, 2011

Copy link to clipboard

Copied

convertProfile (destinationProfile, intent [, blackPointCompensation] [, dither])

That is the javascript syntax of the line you would need to add to your script. The square bracketed parameters are optional the other are required. You need to supply the color profile and intent prams.  If you want to use scripting you need to learn a bit about programming in a scripting language javascript is the best choice for there a version for both the MAC and PC Windows platforms.  There are many script you can download and HACK on then.  Without some knowledge you will not be able to hack. If your do not have the time to read and gain the required khowledge you may want to look into Photoshop  Actions they are much easier to record and edit. It would be very easy to record an action to convert an image to the sRGB color space. The action could then be batched. The file>Automat>Batch... Will open a dialog thtat you use to point to your png folder the action set and action and thers is an option to save and close  them.

A one step action can do what you want. Record ment Edit>Convert to Profile.  In the Convert to Profile dialod use the destination space  pull-down meny and choose sRGB then click OK.  When you play the action no dialog will be displayed the document will just ne converted to the sRGB color space. Batch that Action.

If you know nothing about actions either my crafting actions package may be of some help.

http://www.mouseprints.net/old/dpr/JJMacksCraftingActions.zip

Contains:

Action Actions Palette Tips.txt

Action Creation Guidelines.txt

Action Dealing with Image Size.txt

Action Enhanced via Scripted Photoshop Functions.txt

CraftedActions.atn Sample Action set includes an example Watermarking action http://www.mouseprints.net/old/dpr/WM900x600.jpg

Sample Actions.txt Photoshop CraftedActions set saved as a text file. This file has some additional comments I inserted describing how the actions work.

12 Scripts for actions

Message was edited by: JJMack

JJMack

Votes

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 03, 2016 Jan 03, 2016

Copy link to clipboard

Copied

LATEST

An old thread, but hey…

I would simply do this via an action (because I can’t script, however does one really need a script?), then batch the action on all afflicted files.

The colour swap could be done by recording a mode change to multichannel mode, moving the channel order around, then changing back to RGB mode and assigning sRGB…

However I would probably just use a channel mixer move, B=R and R=B, then assign sRGB.

Channel Mixer

  Preset Kind: Custom

  Output Red: is a mixture of

  Blue: 100%

  Output Green: is a mixture of

  Green: 100%

  Output Blue: is a mixture of

  Red: 100%

I guess another option would be to create a custom sRGB profile and swap the channel order around so that it is BGR, then convert to sRGB – however this would mess with the files numbers/values when the previous two methods would not.

EDIT: If this is needed to fit into a larger scripting workflow, you could just insert the moves for the channel mixer and or assign profile steps. If one is not after elegant code, the ScriptListener plug-in would do the job of recording the moves.

Votes

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