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

Exporting Visible layers in photoshop 2020

Explorer ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

Hi, 

I try to export only visible layer with this script found here :
https://community.adobe.com/t5/photoshop/exporting-visible-layers-in-photoshop-using-script/m-p/8276...

 

But somthing goes wrong with this line :

  var current; // current layer reference

 

have you got an idea ?

thank

TOPICS
Actions and scripting , Windows

Views

501

Translate

Translate

Report

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

Explorer , Nov 18, 2020 Nov 18, 2020

Ok, i fix it :

This script export only visible layer

function exportPNG(){
  var documents = app.activeDocument;
  var docName = app.activeDocument.name;
  var docNameNoExt = app.activeDocument.name.split('.')[0];
  var docPath = app.activeDocument.path.fsName;
  var pngSrvOutput = new Folder("\\\\server_network\\production\\")
  if (!pngSrvOutput.exists){
    pngSrvOutput.create()
  }
  var isVisible = new Array();
  //Show each layer each time and save a snapshot
  for (var i = 0; i < documents.
...

Votes

Translate

Translate
Adobe
Explorer ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

oops, this line, sorry : (just above)

settings = current.visible;

 

Votes

Translate

Translate

Report

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
Explorer ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

ok, try to do it with anoterh way, but it exxport only first layer

var isVisible = new Array();
  //Show each layer each time and save a snapshot
  for (var i = 0; i < documents.layers.length; i++) {
    isVisible = documents.layers[i].visible;
    //Hide all the layers
    for (var j = 0; j < documents.layers.length; j++) {
      documents.layers[j].visible = false;
    }
    // show layer
    var layerIndex = i;
    documents.layers[layerIndex].visible = true;
    var layerName = documents.layers[layerIndex].name;
    // save
    if (isVisible){
      var file = new File(pngSrvOutput + "\\" + docNameNoExt + "_" + layerName + ".png");
      var saveOptions = new PNGSaveOptions();
      documents.saveAs(file, saveOptions, true, Extension.LOWERCASE);
    }
  }

 I would like to export only visible layer

Votes

Translate

Translate

Report

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
Explorer ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Ok, i fix it :

This script export only visible layer

function exportPNG(){
  var documents = app.activeDocument;
  var docName = app.activeDocument.name;
  var docNameNoExt = app.activeDocument.name.split('.')[0];
  var docPath = app.activeDocument.path.fsName;
  var pngSrvOutput = new Folder("\\\\server_network\\production\\")
  if (!pngSrvOutput.exists){
    pngSrvOutput.create()
  }
  var isVisible = new Array();
  //Show each layer each time and save a snapshot
  for (var i = 0; i < documents.layers.length; i++) {
    isVisible[i] = documents.layers[i].visible == true;
    }
  for (var i = 0; i < documents.layers.length; i++){
    //Hide all the layers
    for (var j = 0; j < documents.layers.length; j++) {
      documents.layers[j].visible = false;
    }
    // show layer
    if (isVisible[i]){
      var layerIndex = i;
      documents.layers[layerIndex].visible = true;
      var layerName = documents.layers[layerIndex].name;    // save
      var file = new File(pngSrvOutput + "\\" + docNameNoExt + "_" + layerName + "-1.png");
      var saveOptions = new PNGSaveOptions();
      documents.saveAs(file, saveOptions, true, Extension.LOWERCASE);
    }
  }
  for (var i = 0; i < documents.layers.length; i++){
    documents.layers[i].visible = isVisible[i]
  }
}
exportPNG()

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

That's not exporting single layers, but simple saving visible ones.

Votes

Translate

Translate

Report

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
Explorer ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

That what i want ?!

see top of: 
I try to export only visible layer with this script found here

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

I mean exporting is not the same as saving, and in Photoshop these functions are similar only.

Votes

Translate

Translate

Report

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
Explorer ,
Nov 25, 2020 Nov 25, 2020

Copy link to clipboard

Copied

LATEST

ha, exact !

Votes

Translate

Translate

Report

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