Thursday, March 31, 2011

Color Blind Code WIP

// =======================================================
var image = app.activeDocument;

app.activeDocument.artLayers.getByName("Background");

var newLayer = image.artLayers.add();
var newLayer = image.artLayers.add();
var Layer1 = image.artLayers.getByName("Layer 1");
var Layer2 = image.artLayers.getByName("Layer 2");

var redChannel = image.channels.getByName("Red");
var arrayRed = new Array (redChannel);
image.activeChannels = arrayRed;
image.selection.selectAll();




I wanted to unlock the background layer but none of the help seemed to be working. I was given this code to use but I think because I use PhotoshopCS it wasn't working properly.

if(hasBackground()){
activeDocument.activeLayer = activeDocument.artLayers.getByName("Background");
activeDocument.activeLayer.isBackgroundLayer = false;
}
function hasBackground() {
var ref = new ActionReference();
ref.putProperty(charIDToTypeID("Prpr"), charIDToTypeID("Bckg"));
ref.putEnumerated(charIDToTypeID("Lyr "),charIDToTypeID("Ordn"),charIDToTypeID("Back"));
var desc = executeActionGet(ref);
var res = desc.getBoolean(charIDToTypeID("Bckg"));
return res;
};

No comments:

Post a Comment