-
-
Save sambatlim/3d145f4dc4b2f5d8ef641b18a39ac93c to your computer and use it in GitHub Desktop.
function Main() { | |
var num = 1; | |
for (var j = 0; j < app.activeDocument.layerSets[0].layers.length; j++) { | |
for (var k = 0; k < app.activeDocument.layerSets[1].layers.length; k++) { | |
for (var l = 0; l < app.activeDocument.layerSets[2].layers.length; l++) { | |
var groupChildArr1 = app.activeDocument.layerSets[0].layers; | |
var groupChildArr2 = app.activeDocument.layerSets[1].layers; | |
var groupChildArr3 = app.activeDocument.layerSets[2].layers; | |
app.activeDocument.layerSets[0].visible = true; | |
app.activeDocument.layerSets[1].visible = true; | |
app.activeDocument.layerSets[2].visible = true; | |
groupChildArr1[j].visible = true; | |
groupChildArr2[k].visible = true; | |
groupChildArr3[l].visible = true; | |
Save(num); | |
num++; | |
Revert(); | |
} | |
} | |
} | |
} | |
function Save(num) { | |
var outFolder = app.activeDocument; // psd name | |
var outPath = outFolder.path; | |
var fName = "PNG"; // define folder name | |
var f = new Folder(outPath + "/" + fName); | |
if (!f.exists) { | |
f.create() | |
} | |
var saveFile = new File(outPath + "/" + fName + "/" + "Pattern_" + num + ".png"); | |
pngSaveOptions = new PNGSaveOptions(); | |
pngSaveOptions.interlaced = false; | |
app.activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE); | |
} | |
function Revert() { | |
var idRvrt = charIDToTypeID("Rvrt"); | |
executeAction(idRvrt, undefined, DialogModes.NO); | |
} | |
Main() |
Save your PSD file where you want the output to be saved.
i found this
main();
function main()
{
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
if(Ext.toLowerCase() != 'psd') return;
// assumes the file has already been saved
var Path = app.activeDocument.path;
// Save as PSD
var SaveFile = File(Path + "/" + Name +".psd");
if(SaveFile.exists) SaveFile.remove();
SavePSD(SaveFile);
// Save as PNG
SaveFile = File(Path + "/" + Name +".png");
if(SaveFile.exists) SaveFile.remove();
SavePNG(SaveFile);
alert("File saved as .png and .psd");
}
function SavePNG(saveFile)
{
var pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
function SavePSD(saveFile)
{
var psdFile = new File(saveFile);
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
activeDocument.saveAs(psdFile, psdSaveOptions, false, Extension.LOWERCASE);
}
not working :( i´m gonna die
Im having the same issue. I am also using 2014.
Never try on PS 2014.
I am using CS6. When I browse for your .JS file I cant see it. Does it not work?
Really great tutorial. Which Photoshop version are you using?
Works with PS2020. Great job mate!! Long Live King Lim!!
bybyspalma : i use ur code above and its working on myside i using PS 2020
Hi
I have used this to create static NFTs. I have a character and then need to change background color and icon. I also have animated the characters. How do I change this code to work on an animated character in photoshop or aftereffects? i.e the character is animated and the background color and icon change
I have managed to get the animation into a video group in Photoshop (as a .mov) and then converted my other groups of layers into groups of video groups. As the file goes through the various layers in the group, it needs to be added to a render queue rather than saved as a png.
It would be great if you share your code here.
Hi
Checking to see if you received the email I sent yesterday. Let me know if you are interested.
not working :(