1

I have a psd with ~400 Layers which contain semitransparent images and one layer with a solid color. I want to export those layers to png8 and want that layers to have that solid background. I can export those layers with File->Scripts->Export layers to files, but cannot provide the background option. Any simple way to achieve this?

0

1 Answer 1

1

I've found a solution. After searching quite a bit, I finally found an answer. I wrote a little jpx script, though output is now as jpg.

// variables
var destination = "C:/Users/...../"
var doc = app.activeDocument;
var artlayers = new Array();

// jpeg options
var options = new ExportOptionsSaveForWeb();
options.quality = 80;
options.format = SaveDocumentType.JPEG; 

// loop through all layers
var x = 0;
var a = 0;
while (x < doc.layers.length) {
    // check if the layer is a item
    if (doc.layers[x].kind == LayerKind.NORMAL) {
        // add to array
        artlayers[a] = x;
        a++;
    }
    x++;
}

var x = 0;
var a = 0;

for  (x=0; x < artlayers.length; x++)

{
doc.layers[artlayers[x]].visible = true;
// export as jpeg
try { doc.backgroundLayer.visible = true; } catch (e) {}
file = new File(destination + doc.layers[artlayers[x]].name +".jpg");
doc.exportDocument(file, ExportType.SAVEFORWEB, options); 
doc.layers[artlayers[x]].visible = false;
}

It's important to know, that the background-layer must be an original photoshop background. If the name of the bg-layer is in italics, you're good to go. also, all layers except the bg-layer have to be invisible/deselected.

have fun! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.