Copy link to clipboard
Copied
Hi
I wanted to do the following steps with Actions, but I am unable to do it - maybe because of intellectual or technical limitation. I hope you guys here can help:
I am making icons for a desktop application, and due to how the code is written I need to save each new icon in three almost similar versions
I have an original file in e.g. 16x16 PNG - lets call it "Example.png"
This file needs to be saved first as "Example_16_n_p.png"
Then needs to be saved as "Example_16_h_p.png"
and then have its Mode changed to 'grayscale' and have the opacity changed in the layers menu to 60%, and then saved as "Example_16_d_p.png"
(For those who wonder why: the suffixes is for the Java application to understand: the size of the icon, if the file is used for n=neutral, h=hover, d=disabled, and finally that it should read it as a p=png)
((some of this code is a little redundant as e.g. n and h files are completely the same, but company standards are company standards 🙂 ))
I'd like to just point to a folder where my original files are stored, and have the resulting files saved in a subfolder called e.g. "Commit icons" - not touching the originals.
Anyone?
/Loopy
Please try this...
...#target photoshop
main();
function main(){
var inFolder = Folder.selectDialog("Please select folder to process");
var fileList = inFolder.getFiles("*.png");
if(fileList.length == 0 ) return;
var outputFolder = Folder (inFolder+"/Commit icons");
if(!outputFolder.exists) outputFolder.create();
for(var a in fileList){
var png = open(fileList);
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var saveFile = File(outputFolder + "/" + Name + "_16_n_p.png");
SavePNG(saveFile);
saveFil
Copy link to clipboard
Copied
Please try this...
#target photoshop
main();
function main(){
var inFolder = Folder.selectDialog("Please select folder to process");
var fileList = inFolder.getFiles("*.png");
if(fileList.length == 0 ) return;
var outputFolder = Folder (inFolder+"/Commit icons");
if(!outputFolder.exists) outputFolder.create();
for(var a in fileList){
var png = open(fileList);
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var saveFile = File(outputFolder + "/" + Name + "_16_n_p.png");
SavePNG(saveFile);
saveFile = File(outputFolder + "/" + Name + "_16_h_p.png");
SavePNG(saveFile);
activeDocument.activeLayer.opacity=60;
activeDocument.changeMode(ChangeMode.GRAYSCALE);
saveFile = File(outputFolder + "/" + Name + "_16_d_p.png");
SavePNG(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
};
function SavePNG(saveFile){
pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
WOW. thanks Paul
Worked like a charm!!
You're the Man!
/L