Adobe Photoshop Scripting: (Part-04) Select Layer & Group Layer and change the blending mode of the layer.
Everything in Photoshop is represented as an “object” (e.g., ArtLayer
, Channel
), and each object is part of an array called a “collection” (e.g., ArtLayers
, Channels
).
We must use the collection name, which is a plural form of the object name, as follows:// Get the Current document
var docRef = app.activeDocument;
// Select the “My first layer” layer as the active layer
docRef.activeLayer = docRef.artLayers.getByName (‘My first layer’);
// Select the “This is Group Layer Text” layer as the active layer from the group layer ‘TEXT’.
docRef.activeLayer = docRef.layerSets.getByName (‘TEXT’).layers.getByName(‘This is Group Layer Text’);
// Changing the blend mode of the text layer to Divide (Blending mode must use capital letter (DIVIDE))
var textLayer = docRef.layerSets.getByName (‘TEXT’).layers.getByName(‘This is Group Layer Text’);
textLayer.blendMode = BlendMode.DIVIDE;
Code Explanations: