Copy link to clipboard
Copied
I've been working on a script to loop through my layersets and export them to the desktop. Everything is working but it's not saving the tiff to the temp folder. The other thing I'm wondering about are the tiff save options, how would I add those? Any help/insight would be appriciated.
var doc = app.activeDocument;
// Set up the output location
var folder = new Folder("~/Desktop/TestFolder");
folder.create();
// Check if the document has any layer sets
if (doc.layerSets.length == 0) {
alert("The document does not have any layer sets!");
}
// Loop through all the layer sets in the document
for (var i = 0; i < doc.layerSets.length; i++) {
var layerSet = doc.layerSets[i];
// Set up the output file name and location
var fileName = layerSet.name + ".tif";
// Skip the layer set named "Book Board"
if (layerSet.name == "Book Board") {
continue;
}
// Export the layer set as a TIFF file
new File("~/Desktop/TestFolder/" + fileName);
// Turn off the layer set
layerSet.visible = false;
}
An example for saving a tiff off of an open file.
var myDocument = app.activeDocument;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
saveCopyAsTif (app.activeDocument, "~/Desktop/"+basename+"_x"+".tif");
////// save pdf //////
function saveCopyAsTif (myDocument, thePath) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrd
...
Copy link to clipboard
Copied
Your Script includes no save operation so naturally nothing is being saved.
Copy link to clipboard
Copied
An example for saving a tiff off of an open file.
var myDocument = app.activeDocument;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
saveCopyAsTif (app.activeDocument, "~/Desktop/"+basename+"_x"+".tif");
////// save pdf //////
function saveCopyAsTif (myDocument, thePath) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
// save copy;
myDocument.saveAs((new File(thePath)), tifOpts, true);
};
Copy link to clipboard
Copied
Ahh, for some reason I was thinking that just using new File() I was generating the file. Thank you!