Adobe 23102480 Scripting Guide - Page 33

Setting Application Preferences' on Crop the image., Flip the entire window.

Page 33 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85

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