3 Replies Latest reply on Sep 15, 2016 3:24 PM by Vfxvenkat98

    Make Background layer and top layer visible

    Vfxvenkat98 Level 1

      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;

      }; 

        • 1. Re: Make Background layer and top layer visible
          Pedro Cortez Marques Level 3

          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_[b].visible = false;
                  }
                  layerSets_[a].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_[a].name+'.jpg'),jpegOptions,true); 
                  //thanks to xbytor;
              }
          };
          
          • 2. Re: Make Background layer and top layer visible
            JJMack Most Valuable Participant

            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

            • 3. Re: Make Background layer and top layer visible
              Vfxvenkat98 Level 1

              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.