
C
HAPTER
3: Scripting Photoshop
Working with the Photoshop Object Model
36
'Crop the document with
' angle=45, width=20,height=20
docRef.Crop Array(100,200,400,500),45,20,20
docRef.FlipCanvas 1 ' psHorizontal
'restore ruler units
appRef.Preferences.RulerUnits = startRulerUnits
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 object model contains two types of layer objects:
➤
ArtLayer
objects, which can contain image contents and are basically equivalent to Layers in the
Photoshop application.
N
OTE
:
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
.
N
OTE
:
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.
Содержание 65048332
Страница 1: ...SCRIPTING GUIDE ADOBE PHOTOSHOP CS5...