Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Layer Comps to Files flatten tiff

Community Beginner ,
Nov 13, 2017 Nov 13, 2017

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.

TOPICS
Actions and scripting
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Nov 13, 2017 Nov 13, 2017

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

...
Translate
Adobe
People's Champ ,
Nov 13, 2017 Nov 13, 2017

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 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 13, 2017 Nov 13, 2017

That works perfectly. Thanks so much r-bin, that was incredibly helpful!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 16, 2017 Nov 16, 2017

Oh man, how was this posted two days before I needed it! Thanks so much!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2022 Mar 23, 2022

You are a legend!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2024 Jun 07, 2024
LATEST

THis beautiful chunk of code just saved me 3-4 hours and tons of potential for error every day. This should be incorporated into actual PS. THANK YOU!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 21, 2018 Dec 21, 2018

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();

~Roy
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 21, 2018 Dec 21, 2018

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();

~Roy
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines