Skip to main content
Vfxvenkat98
Known Participant
September 14, 2016
Question

Make Background layer and top layer visible

  • September 14, 2016
  • 3 replies
  • 748 views

hi,

     How to save layersets along with Background layer and top layer.

Here is the script to save current active layerset as .jpg format but when i try to use the (for loop) to save all the layersets  one by one bottom order it current turn off's the background layer and top layer.

But i dont know how to run this via looping to make the active layer one by one along bottom and top layer

Anyone help on this to fix this script

#target photoshop; 

if (app.documents.length > 0) { 

var thedoc = app.activeDocument; 

// getting the name and location; 

var docName = thedoc.name; 

if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]} 

else {var basename = docName}; 

// getting the location, if unsaved save to desktop; 

try {var docPath = thedoc.path} 

catch (e) {var docPath = "~/Desktop"}; 

// jpg options; 

var jpegOptions = new JPEGSaveOptions(); 

jpegOptions.quality = 12; 

jpegOptions.embedColorProfile = true; 

jpegOptions.matte = MatteType.NONE; 

//save jpg in layerset name: 

thedoc.saveAs((new File(docPath+'/'+thedoc.activeLayer.name+'.jpg')),jpegOptions,true); 

//thanks to xbytor;

}; 

This topic has been closed for replies.

3 replies

Vfxvenkat98
Known Participant
September 15, 2016

Thanks a lot Pedro Cortez Marques,JJMack Pedro Cortez Marques

But currently it processing all the layer sets in the active document if it is possible to unprocess a particular named group

eg; in the document there is an layer group called Masks above this masks group all my actual layersets are there so basically i need to process all the groups above the masks group and not the layer groups below Masks layergroups.

JJMack
Community Expert
Community Expert
September 14, 2016

Quick Top and Bottom of a documents visibility ON will not change the visibility state of layes within top and botton  layer Groups.

var layers = activeDocument.layers;

layers[0].visible=true; // Top Layer or Layer Group

layers[layers.length-1].visible=true;    // Background Layer or Bottom Layer or Group

JJMack
Pedro Cortez Marques
Legend
September 14, 2016

Hi. I hope it helps.

#target photoshop;

if (app.documents.length > 0) {

    var thedoc = app.activeDocument;

    // getting the name and location;

    var docName = thedoc.name;

    if (docName.indexOf(".") != -1) {

        var basename = docName.match(/(.*)\.[^\.]+$/)[1];

    } else {

        var basename = docName;

    };

    // getting the location, if unsaved save to desktop;

    try {

        var docPath = thedoc.path}

    catch (e) {

        var docPath = "~/Desktop"

    };

    //

    var layerSets_ = app.activeDocument.layerSets;

    for (var a =0; a < layerSets_.length; a++) {

        // turn all layerSets invisible

        for (var b =0; b < layerSets_.length; b++) {

            layerSets_.visible = false;

        }

        layerSets_.visible = true;

        // jpg options;

        var jpegOptions = new JPEGSaveOptions();

        jpegOptions.quality = 12;

        jpegOptions.embedColorProfile = true;

        jpegOptions.matte = MatteType.NONE;

        //save jpg in layerset name:

        thedoc.saveAs(new File(Folder.desktop + '/backup/'+layerSets_.name+'.jpg'),jpegOptions,true);

        //thanks to xbytor;

    }

};