Adobe 23102480 Scripting Guide - Page 34
Working with Layer Objects, Creating an ArtLayer Object, Photoshop CS3 application.
UPC - 883919080222
View all Adobe 23102480 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 34 highlights
Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 34 JS //save original ruler units, then assign it to inches startRulerUnits = app.preferences.rulerUnits app.preferences.rulerUnits = Units.INCHES //get a reference to the file, and open it var fileRef = new File(app.path + "/samples/ducky.tif") var docRef = app.open(fileRef) //this sample script assumes the ruler units have been set to inches docRef.resizeImage( 4,4 ) docRef.resizeCanvas( 4,4 ) docRef.trim(TrimType.TOPLEFT, true, false, true, false) //the crop command uses unit values //so change the ruler units to pixels app.preferences.rulerUnits =Units.PIXELS docRef.crop (new Array(100,200,400,500), 45, 20, 20) docRef.flipCanvas(Direction.HORIZONTAL) //restore original preferences app.preferences.rulerUnits = startRulerUnits Working with Layer Objects The Photoshop CS3 object model contains two types of layer objects: ● ArtLayer objects, which can contain image contents and are basically equivalent to Layers in the Photoshop CS3 application. Note: An ArtLayer object can also contain text if you use the kind property to set the ArtLayer object's type to text layer. ● Layer Set objects, which can contain zero or more ArtLayer objects. When you create a layer you must specify whether you are creating an ArtLayer or a Layer Set. Note: Both the ArtLayer and LayerSet objects have corresponding collection objects, ArtLayers and LayerSets, which have an add/Add/add() command.You can reference, but not add, ArtLayer and LayerSet objects using the Layers collection object, because, unlike other collection objects, it does not have an add/Add/add() command. Creating an ArtLayer Object The following examples demonstrate how to create an ArtLayer object filled with red at the beginning of the current document. AS tell application "Adobe Photoshop CS3" make new document make new art layer at beginning of current document ¬ with properties {name:"MyBlendLayer", blend mode:normal} select all current document fill selection of current document with contents ¬ {class:RGB color, red:255, green:0, blue:0} end tell