3.8.3 Document manipulation
The Document object is used to make modifications to the document image. By using the
Document object you can crop, rotate or flip the canvas, resize the image or canvas, and trim
the Image.
Because unit values are passed in when resizing an image, it is recommended that you first set
your ruler units prior to resizing. See section
for more information.
The examples in this section assume that the ruler units have been set to inches.
To resize the image so that it is four inches wide by four inches high, use the document's
resize (Resize/resize) command.
AS: resize image current document width 4 height 4
VB: docRef.ResizeImage 4,4
JS:
Resizing the canvas is done similarly.
AS: resize canvas current document width 4 height 4
VB: docRef.ResizeCanvas 4,4
JS:
To trim the excess space from a document, use the trim (Trim/trim) command. The
example below will trim the top and bottom of the document.
AS:
trim current document basing trim on top left pixel ¬
VB:
docRef.Trim Type:=psTopLeftPixel, Top:=True, Left:=False, _
JS:
docRef.trim(TrimType.TOPLEFT, true, false, true, false);
N
O T E
AS:
crop current document bounds {10, 20, 40, 50} angle 45 ¬
VB:
docRef.Crop Array(10,20,40,50), Angle:=45, Width:=20, _
Photoshop 7.0 Scripting Guide
docRef.resizeImage( 4,4 );
docRef.resizeCanvas( 4,4 );
with top trim and bottom trim without left trim and right trim
Bottom:=True, Right:=False
The crop command uses unit values. The examples below assume that the ruler unit is
:
set to pixels.
resolution 72 width 20 height 20
Height:=20, Resolution:=72
Scripting Photoshop
3.5.3, "Changing ruler and type units" on page 48
3
Document object
57