Skip to main content
Chris Panny
Inspiring
November 2, 2014
Question

Photoshop CS6 - How can javaScript fill blank layer with color?

  • November 2, 2014
  • 1 reply
  • 1326 views

Hello,

I'm a production artist and I work with PSD files that were created in Adobe Scene7 Image Authoring Tool. These PSDs contain a background layer along with 1-20 alpha channels. My script has to make new blank layers based on the number of alpha channels and then it has to fill the new layers with light gray. The RGB values are 161, 161, 161. I checked the PSCS6 JavaScript Reference pdf, but I don't see a method that would do this for artLayers. (Let me also say that I'm new to javaScript).

Does anyone know how to fill a blank layer with these RGB values?

Here's my script so far:

#target photoshop 

// declare variable to contain the active document

var myDoc=app.activeDocument;

// declare variable to contain the number of alpha channels, excluding the RGB channels

var alphaChan = myDoc.channels.length - 3;

// create loop to make new layers based on number of alpha channels and fill each layer with gray

for (a=0; a<alphaChan; a=+1){

myDoc.artLayers.add();

if (myDoc.artLayers.length == (alphaChan + 1)) {

    break;

    }

};

This topic has been closed for replies.

1 reply

Inspiring
November 2, 2014

var color = new SolidColor();

color.rgb.red = 161;

color.rgb.green = 161;

color.rgb.blue= 161;

myDoc.selection.fill(color);

Chris Panny
Inspiring
November 2, 2014

that did it! Thanks so much for your help....

-c

It's only an island if you look at it from the water.