Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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! :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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