Skip to main content
Inspiring
September 21, 2010
Question

Apply adjustment to affect all layers when xport layers to files

  • September 21, 2010
  • 2 replies
  • 1000 views

Hi.

Have a set of sequence images opened with Bridge and placed in photoshop as individual layers. I´ve croped the image and

applyed som adjusments eg. curves etc. Now i want to save the layers as files from the file-scripts having the layer adjustments affecting

my layers before saving.

/Tedski

This topic has been closed for replies.

2 replies

tedskiAuthor
Inspiring
September 23, 2010

I went to javascript forums where i got help editing *.jsx for photoshop, so it now applies adjustment to every single layer before saving as a file.

Thanks all for your time.

/Tedski

c.pfaffenbichler
Community Expert
Community Expert
September 25, 2010

Well, you don’t need it anymore, but I still gave a Script that saves the pixel-layers as separate files with the Adjustment Layers flattened in a try; only for psd, though, so no format-selection.

If you want to give it a try …

// create psd-copies of  all pixel-layers with adjustment layers applied to them;

// thanks to xbytor for the regexp;

// 2010, use at your own risk;

#target photoshop

if (app.documents.length > 0) {

  var thedoc = app.activeDocument;

var docName = thedoc.name;

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

// get path;

  try {var docPath = thedoc.path}

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

// duplicate;

  var myDocument = thedoc.duplicate ("thecopy", false);

  var theLayers = hideAndCollectPixelLayers(myDocument);

  var theArtLayers = new Array

  if (theLayers.length > 1) {

// show one layer and save psd;

    for (var m = 0; m < theLayers.length; m++) {

      var aLayer = theLayers;

      aLayer.visible = true;

      savePsd (myDocument, aLayer.name, docPath, basename);

      aLayer.visible = false;

      };

    };

// close duplicate;

  myDocument.close(SaveOptions.DONOTSAVECHANGES)

  };

////////////////////////////////////

////////////////////////////////////

////////////////////////////////////

////// function to collect all pixel-layers and hide them //////

function hideAndCollectPixelLayers (theParent) {

if (!allLayers) {

var allLayers = new Array}

else {};

for (var m = theParent.layers.length - 1; m >= 0;m--) {

var theLayer = theParent.layers;

// apply the function to layersets;

    if (theLayer.typename == "ArtLayer") {

// process pixel-layers;

      if (theLayer.kind == "LayerKind.GRADIENTFILL" || theLayer.kind == "LayerKind.LAYER3D" || theLayer.kind == "LayerKind.NORMAL" ||

      theLayer.kind == "LayerKind.PATTERNFILL" || theLayer.kind == "LayerKind.SMARTOBJECT" || theLayer.kind == "LayerKind.SOLIDFILL" ||

      theLayer.kind == "LayerKind.TEXT" || theLayer.kind == "LayerKind.VIDEO") {

        theLayer.visible = false;

        allLayers.push(theLayer)

        }

      }

    else {

allLayers = allLayers.concat(hideAndCollectPixelLayers(theLayer))

// this line includes the layer groups;

// allLayers.push(theLayer);

      }

    };

  return allLayers

};

////// function to save psds //////

function savePsd (myDocument, layerName, docPath, basename) {

// this clause changes the name if a file of that name exists in that location;

  while (File(docPath+'/'+basename+"_"+layerName+".psd").exists == true) {

    layerName = layerName+"_"+"1"

    };

  var thecopy = myDocument.duplicate (thecopy, true);

psdOpts = new PhotoshopSaveOptions();

psdOpts.embedColorProfile = true;

psdOpts.alphaChannels = false;

psdOpts.layers = true;

psdOpts.spotColors = true;

thecopy.saveAs((new File(docPath+'/'+basename+"_"+layerName+".psd")),psdOpts,true);

thecopy.close(SaveOptions.DONOTSAVECHANGES)

  };

c.pfaffenbichler
Community Expert
Community Expert
September 22, 2010

It’s certainly possible to achieve something like that.

But I think it might be easier to start with a new Script and do without the dialog at all instead of trying to change the existing one.

How experienced are you with JavaScript?

tedskiAuthor
Inspiring
September 22, 2010

Hi c.pfaff......

Not good enough to script photoshop i guess. Maybe i´m doing it the wrong way all together. Is it another way of adjust multiple files without bringing them into photoshop as layers?

/Tedski

c.pfaffenbichler
Community Expert
Community Expert
September 22, 2010

One could create a Script that offers a dialog to select files (or a folder) and subsequently opens and adds the Adjustments to all those files.

If nobody else has some Scripts ready for this or the original task I might give it a look on the weekend.

But you might also search or ask at http://www.ps-scripts.com/