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

Saving layer comps as .png with custom filenames

Community Beginner ,
Mar 30, 2009 Mar 30, 2009
I'm using an action to create 30 layercomps from my .psd.

I need to save those out as .png files with a filename like this...

DocName_E00_S01.png

So "DocName" is the existing filename, "E" always stays the same, "00" is a 2 digit serial number that matches the name of the layercomp, and "S01" is text that I enter for the entire set of layercomps.

I've tried so many ways to solve this, but I'm a total js newbie.
Can anyone help?
TOPICS
Actions and scripting
1.1K
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
Adobe
Community Expert ,
Mar 30, 2009 Mar 30, 2009
Which part can't you do? Do you know how to export as PNG?
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 Expert ,
Mar 30, 2009 Mar 30, 2009
If it is about the way in which to write the documentname and -path this might help, I didnt bother to change it to png though:


// for getting tiffs of layercomps;

#target photoshop

var myDocument = app.activeDocument;

// getting the name and location, thanks to xbytor;

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

var docPath = myDocument.path;

// tiff options;

tifOpts = new TiffSaveOptions();

tifOpts.embedColorProfile = true;

tifOpts.imageCompression = TIFFEncoding.TIFFLZW;

tifOpts.alphaChannels = false;

tifOpts.byteOrder = ByteOrder.MACOS ;

tifOpts.layers = true;

// create the versions;

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

// apply the layer comp;

myDocument.layerComps.apply();

var theLayerCompName = myDocument.layerComps.name;

// duplicate the image;

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

// save the tiff;

thecopy.saveAs((new File(docPath+"/"+basename+"_E"+theLayerCompName+"_S01.tif")),tifOpts,true);

thecopy.close(SaveOptions.DONOTSAVECHANGES);

app.activeDocument = myDocument;

};
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 ,
Mar 30, 2009 Mar 30, 2009
LATEST
Try67, I found a script hack of the layercomps to files script to get the png. instead of the other file types included in the default script.
But I need both specifically a png, and filename script.

It seems if I start this script by defining the png options, then adjust the end of the script to save as png, it would work.

Christopher, I really appreciate the syntax you've updated to fix my name.

I'll try my hand at the png portion and upload it when/if I get it working.

xBytor thanks for the original syntax.
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