Trim - Adobe 19400084 - Photoshop CS3 Extended Manual

Javascript scripting reference
Table of Contents

Advertisement

JavaScript Scripting Reference
Method

trim

([type]
[, top]
[, left]
[, bottom]
[, right])
Sample Script
The following script creates a document that contains two images (a flower and a duck) obtained from the
Adobe Photoshop CS3 Samples folder and employs the following steps:
Determines which image is larger.
Resizes the smaller image to match the larger image.
Creates a merged document twice as high as either image in order to hold both images.
Selects part of the document to and pastes the flower into the selection.
Inverts the selection and pastes the duckinto the lower part of the document.
Positions the flower over the duck.
Document.jsx
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// Set Adobe Photoshop CS3 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
// first close all the open documents
while (app.documents.length) {
app.activeDocument.close()
}
// Open the sunflower and duck files from the samples folder
var flowerDoc = open(File(app.path + "/Samples/Sunflower.psd"))
var duckDoc = open(File(app.path + "/Samples/Ducky.tif"))
// Find out which document is larger
// Resize the smaller document the to the larger document's size
// The resize requires the document be the active/front document
if ((flowerDoc.width.value * flowerDoc.height.value) > (duckDoc.width.value *
duckDoc.height.value)) {
app.activeDocument = duckDoc
duckDoc.resize(flowerDoc.width, flowerDoc.height)
} else {
app.activeDocument = flowerDoc
flowerDoc.resizeImage(duckDoc.width, duckDoc.height)
}
// Create a new document twice as high as two files
Adobe Photoshop CS3
Parameter Type
TrimType
boolean
boolean
boolean
boolean
JavaScript Object Reference
Returns
What it does (Continued)
Trims the transparent area
around the image on the
specified sides of the
canvas.
Note:
Default is
boolean values.
96
for all
true

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs3

Table of Contents