
Photoshop CS3
Adobe Photoshop CS3 Scripting Guide Scripting Photoshop CS3 33
● Crop the image.
● Flip the entire window.
● Restore the original ruler units.
Note: See ‘Setting Application Preferences’ on page 30
for information on ruler units.
AS
tell application "Adobe Photoshop CS3"
set saveUnit to ruler units of settings
set ruler units of settings to inch units
set duckFile to alias ¬
"OS X 10.4.8 US:Applications:Adobe Photoshop CS3:Samples:Ducky.tif"
open duckFile
set docRef to current document
resize image docRef width 4 height 4
resize canvas docRef width 4 height 4
trim docRef basing trim on top left pixel with top trim ¬
and bottom trim without left trim and right trim
set ruler units of settings to pixel units
crop current document bounds {100, 200, 400, 500} angle 45 width 20 height 20
flip canvas docRef direction horizontal
set ruler units of settings to saveUnit
end tell
VBS
Dim appRef, docRef
Set appRef = CreateObject("Photoshop.Application")
'save original ruler units, then set ruler units to inches
startRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = 2 'for PsUnits --> 2 (psInches)
Set docRef = appRef.Open(appRef.Path & "\Samples\Ducky.tif")
docRef.ResizeImage 4,4
docRef.ResizeCanvas 4,4
'Trim the document with
' type = 1 (psTopLeftPixel)
' top=true, left=false, bottom=true, right=false
docRef.Trim 1,True,False,True,False
'the crop command uses unit values
'so change the ruler units to pixels
appRef.Preferences.RulerUnits = 1 ' (psPixels)
'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