Thursday, March 31, 2011

Color Blind Final Code

// =======================================================Selects the background layer and makes a copy. Note that the initial layer you begin with MUST be called background and be locked.
var image = app.activeDocument;
var background = app.activeDocument.artLayers.getByName("Background");
background.duplicate();
background.visible = false;
var copy = image.artLayers.getByName("Background copy");
// =======================================================Makes 2 new layers and names them.
var newLayer = image.artLayers.add();
var newLayer = image.artLayers.add();

var Layer1 = image.artLayers.getByName("Layer 1");
var Layer2 = image.artLayers.getByName("Layer 2");
// =======================================================Makes the active layer the copied layer.
image.activeLayer = copy;
// =======================================================Goes into the channels and copies the red channel to a new layer.
var redChannel = image.channels.getByName("Red");
var arrayRed = new Array (redChannel);
image.activeChannels = arrayRed;
image.selection.selectAll();
image.selection.copy();
image.activeLayer = Layer1;
image.paste();
// =======================================================Does the same for the green but also makes it a screen layer and changes the opacity to 50%.
var greenChannel = image.channels.getByName("Green");
var arrayGreen = new Array (greenChannel);
image.activeChannels = arrayGreen;
image.selection.selectAll();
image.selection.copy();
image.activeLayer = Layer2;
image.paste();
image.activeLayer.blendMode = BlendMode.SCREEN;
Layer2.opacity = 50;
// =======================================================Makes the original image visible again then copies it's newly made green/red channel layers and goes into the channel box and pastes them in as the new red channel and green channel.
copy.visible = false;
image.mergeVisibleLayers();
image.selection.selectAll();
image.selection.copy();

copy.visible = true;
image.activeLayer = copy;

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

var greenChannel = image.channels.getByName("Green");
var arrayGreen = new Array (greenChannel);
image.activeChannels = arrayGreen;
image.paste();
// =======================================================Makes the merged layer invisible then flattens the visible image.
image.activeLayer = Layer2;
Layer2.visible = false;
image.flatten();
image.selection.deselect();

 

No comments:

Post a Comment