Reputation: 1
I would like to know if it's possible to make a photshop action which does the following in a single psd file:
Is there any way to code this? I've been searching around for some time now and I can't find anything even remotely related.
Many thanks!
Upvotes: 0
Views: 511
Reputation: 6949
You're not going to find the code you need for your specific needs just lying around on the internet.
Life's not that easy.
There are however, plenty of places to pick up the basic concepts. Here's the bare bones of what you need. I suggest you modify it with a loop:
// call the source document
var srcDoc = app.activeDocument
// get layer "one"
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("one");
// set it's visibility to be true
app.activeDocument.activeLayer.visible = true;
// get layer "two"
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("two");
// set it to ve invisible
app.activeDocument.activeLayer.visible = false;
// set the name of the file here [CHANGE THIS]
var filePath = "c:\mypath\name_01.jpg";
// save as jpeg
save_as_jpeg(filePath);
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("one");
app.activeDocument.activeLayer.visible = false;
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("two");
app.activeDocument.activeLayer.visible = true;
// set the name of the file here [CHANGE THIS]
filePath = "c:\mypath\name_02.jpg";
// save as jpeg
save_as_jpeg(filePath);
function save_as_jpeg(filePath)
{
// Flatten the jpg
activeDocument.flatten();
// jpg file options
var jpgFile = new File(filePath);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = myJpgQuality;
activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
//close without saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
What you're looking for is a way to take the above code and loop over it so it does layers one through to twenty.
Upvotes: 0