Adobe 23101764 Scripting Guide - Page 75

Document manipulation

Page 75 highlights

Scripting Photoshop 3 Document object 3.9.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 3.6.3, "Changing ruler and type units" on page 61 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: docRef.resizeImage( 4,4 ); Resizing the canvas is done similarly. AS: resize canvas current document width 4 height 4 VB: docRef.ResizeCanvas 4,4 JS: docRef.resizeCanvas( 4,4 ); 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 ¬ with top trim and bottom trim without left trim and right trim VB: docRef.Trim Type:=psTopLeftPixel, Top:=True, Left:=False, _ Bottom:=True, Right:=False JS: docRef.trim(TrimType.TOPLEFT, true, false, true, false); NOTE: The crop command uses unit values. The examples below assume that the ruler unit is set to pixels. AS: crop current document bounds {10, 20, 40, 50} angle 45 ¬ resolution 72 width 20 height 20 VB: docRef.Crop Array(10,20,40,50), Angle:=45, Width:=20, _ Height:=20, Resolution:=72 Photoshop CS Scripting Guide 71

  • 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
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
71
Scripting Photoshop
Document object
3
3.9.3
Document manipulation
The
Document
object is used to make modi
cations to the document image. By using the
Document
object you can crop, rotate or
ip 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
rst set
your ruler units prior to resizing. See section
3.6.3, “Changing ruler and type units” on page 61
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:
docRef.resizeImage( 4,4 );
Resizing the canvas is done similarly.
AS:
resize canvas current document width 4 height 4
VB:
docRef.ResizeCanvas 4,4
JS:
docRef.resizeCanvas( 4,4 );
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 ¬
with top trim and bottom trim without left trim and right trim
VB:
docRef.Trim Type:=psTopLeftPixel, Top:=True, Left:=False, _
Bottom:=True, Right:=False
JS:
docRef.trim(TrimType.TOPLEFT, true, false, true, false);
N
OTE
:
The crop command uses unit values. The examples below assume that the ruler unit is
set to pixels.
AS:
crop current document bounds {10, 20, 40, 50} angle 45 ¬
resolution 72 width 20 height 20
VB:
docRef.Crop Array(10,20,40,50), Angle:=45, Width:=20, _
Height:=20, Resolution:=72