Copy link to clipboard
Copied
Can anyone provide a modification to the javascript Layer Comps to Files that will add a checkbox option to save as a flattened TIFF? Or it could just be a script that executes the save as TIFF format with no layers, just like the option in Save As. I know I can do a workaround to flatten the layered TIFF files the script saves, but it would save a lot of time if that feature was built into the script. My layered files are big enough that reprocessing the large layered TIFF files is an added step I would like to avoid.
Save a copy of your original "Layer Comps To Files.jsx" file.
Then
----------------------------------------------
1) In the file, find the lines
// -- now after all the radio buttons
dlgMain.cbIcc = dlgMain.pnlFileType.add("checkbox", undefined, strCheckboxIncludeICCProfile);
dlgMain.cbIcc.value = exportInfo.icc;
dlgMain.cbIcc.alignment = 'left';
//********************************************************
dlgMain.cbLay = dlgMain.pnlFileType.add("checkbox", undefined, "Include Layer
...Copy link to clipboard
Copied
Save a copy of your original "Layer Comps To Files.jsx" file.
Then
----------------------------------------------
1) In the file, find the lines
// -- now after all the radio buttons
dlgMain.cbIcc = dlgMain.pnlFileType.add("checkbox", undefined, strCheckboxIncludeICCProfile);
dlgMain.cbIcc.value = exportInfo.icc;
dlgMain.cbIcc.alignment = 'left';
//********************************************************
dlgMain.cbLay = dlgMain.pnlFileType.add("checkbox", undefined, "Include Layers");
dlgMain.cbLay.value = exportInfo.layers;
dlgMain.cbLay.alignment = 'left';
//********************************************************
Insert the 3 lines that are between // ******************************************** comments and which are not in the original file
----------------------------------------------
2) In the file, find the lines
// get setting from dialog
exportInfo.destination = dlgMain.etDestination.text;
exportInfo.fileNamePrefix = dlgMain.etFileNamePrefix.text;
exportInfo.selectionOnly = dlgMain.cbSelection.value;
exportInfo.fileType = dlgMain.ddFileType.selection.index;
exportInfo.icc = dlgMain.cbIcc.value;
//********************************************************
exportInfo.layers = dlgMain.cbLay.value;
//********************************************************
Insert the 1 line that is between // ******************************************** comments and which are not in the original file
----------------------------------------------
3) In the file, find the lines
function initExportInfo(exportInfo)
{
exportInfo.destination = new String("");
exportInfo.fileNamePrefix = new String("untitled_");
exportInfo.selectionOnly = false;
exportInfo.fileType = psdIndex;
exportInfo.icc = true;
//*********************************************
exportInfo.layers = true;
//*********************************************
Insert the 1 line that is between // ******************************************** comments and which are not in the original file
----------------------------------------------
4) In the file, find the lines
case psdIndex:
fileExtension = "psd";
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".psd");
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = exportInfo.icc;
//*******************************
psdSaveOptions.layers = exportInfo.layers;
//*******************************
docRef.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
break;
case tiffIndex:
fileExtension = "tiff";
var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".tif");
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = exportInfo.icc;
//*******************************
tiffSaveOptions.layers = exportInfo.layers;
//*******************************
tiffSaveOptions.imageCompression = exportInfo.tiffCompression;
if (TIFFEncoding.JPEG == exportInfo.tiffCompression) tiffSaveOptions.jpegQuality = exportInfo.tiffJpegQuality;
docRef.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
break;
Insert the 2 lines that are between // ******************************************** comments and which are not in the original file
----------------------------------------------
5) Good luck )
Copy link to clipboard
Copied
That works perfectly. Thanks so much r-bin, that was incredibly helpful!
Copy link to clipboard
Copied
Oh man, how was this posted two days before I needed it! Thanks so much!
Copy link to clipboard
Copied
You are a legend!
Copy link to clipboard
Copied
Hi all,
The layered tiff option works great but I have some additional feature requests.
When using the Export Layer Comps to files script you get a named psd/tiff with all the layers, including the layer comps. The file sizes I'll be dealing with will only allow psb exports which isn't practical.
What would be exceptionally useful is at the point of making the new doc, the layers would merge, extra channels/paths/layer comps removed as shown in this stand alone script we use now.
In the end the the saved psd/tiff would be a single layer on a transparent background, no channels/paths/layer comps/merged into one layer. What do you think?
app.bringToFront();
var theImage = app.activeDocument;
theImage.channels.removeAll();
theImage.pathItems.removeAll();
theImage.layerComps.removeAll();
theImage.mergeVisibleLayers();
Copy link to clipboard
Copied
Got it.
//******** look for
var duppedDocument = app.activeDocument.duplicate();
var fileNameBody = exportInfo.fileNamePrefix ;
//******inset 5 lines after
var mergeImage = app.activeDocument;
mergeImage.channels.removeAll();
mergeImage.pathItems.removeAll();
mergeImage.layerComps.removeAll();
mergeImage.mergeVisibleLayers();