Adobe 23101335 Scripting Guide - Page 57

Document manipulation, docRef.Trim Type:=psTopLeftPixel, Top:=True, Left:=False

Page 57 highlights

Scripting Photoshop 3 Document object 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 3.5.3, "Changing ruler and type units" on page 48 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 7.0 Scripting Guide 57

  • 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

Photoshop 7.0 Scripting Guide
57
Scripting Photoshop
Document object
3
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
3.5.3, “Changing ruler and type units” on page 48
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