Adobe 65015634 Scripting Guide - Page 35
Manipulating a document object, Setting Application Preferences
UPC - 883919159232
View all Adobe 65015634 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 35 highlights
CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit preferences, and set ruler units to inches ➤ Open an existing file as a document (using file Ducky.tif) ➤ Change the size of the image to 4 inches wide and 4 inches high. ➤ Change the size of the document window (or canvas) to 4 inches high and 4 inches wide. ➤ Trim the top and bottom of the image. ➤ Crop the image. ➤ Flip the entire window. ➤ Restore the original ruler units. NOTE: See "Setting Application Preferences" on page 32 for information on ruler units. AS tell application "Adobe Photoshop CS4" 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 CS4: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)