ADOBE PHOTOSHOP CS4
JAVASCRIPT SCRIPTING REFERENCE
Revision 1
bbc
© 2008 Adobe Systems Incorporated. All rights reserved.
Adobe® Creative Suite® 4 Photoshop
®
JavaScript Scripting Reference for Windows® and Macintosh®.
NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or
electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior written consent of Adobe Systems Incorporated. The software described in this document is furnished under
license and may only be used or copied in accordance with the terms of such license.
This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and
all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual
organization.
®
, the Adobe logo, Acrobat®, GoLive®,InDesign®, Illustrator®, Photoshop® are either registered trademarks or trademarks of Adobe
Adobe
Systems Incorporated in the United States and/or other countries.
Apple®, Mac OS®, and Macintosh® are trademarks of Apple Computer, Inc., registered in the United States and other countries. Microsoft®, and
Windows
all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. UNIX
®.
are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. JavaScriptTM and
®
is a
registered trademark of The Open Group.
All other trademarks are the property of their respective owners.
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished
under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part
of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording,
or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected
under copyright law even if it is not distributed with software that includes an end user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies that may appear in the informational content contained in this guide.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.
Contents
1 Introduction ............................................................................................................................... 33
JavaScript support in Adobe Photoshop CS4 ....................................................................................................................33
Executing scripts ....................................................................................................................................................................34
Installing scripts ...............................................................................................................................................................34
Executing other scripts..................................................................................................................................................34
Startup scripts .........................................................................................................................................................................34
Object model usage and naming...........................................................................................................................................35
Changes since earlier versions - CS4 changes ...................................................................................................................35
.............................................................................................................................................................................................................36
2 JavaScript Object Reference ..................................................................................................... 37
Object descriptions......................................................................................................................................................................37
Properties notation ...............................................................................................................................................................37
displayDialogs.................................................................................................................................................................37
Methods notation ..................................................................................................................................................................37
crop.....................................................................................................................................................................................38
ActionDescriptor ..........................................................................................................................................................................39
Properties..................................................................................................................................................................................39
count ..................................................................................................................................................................................39
typename .........................................................................................................................................................................39
Methods ....................................................................................................................................................................................39
clear ....................................................................................................................................................................................39
erase ...................................................................................................................................................................................39
fromStream......................................................................................................................................................................39
getBoolean.......................................................................................................................................................................39
getClass .............................................................................................................................................................................39
getData..............................................................................................................................................................................39
getDouble ........................................................................................................................................................................39
getEnumerationType ...................................................................................................................................................39
getEnumerationValue..................................................................................................................................................39
getInteger.........................................................................................................................................................................39
getKey................................................................................................................................................................................39
getList ................................................................................................................................................................................40
getObjectType................................................................................................................................................................40
getObjectValue...............................................................................................................................................................40
getPath ..............................................................................................................................................................................40
getReference ...................................................................................................................................................................40
getString ...........................................................................................................................................................................40
getType .............................................................................................................................................................................40
getUnitDoubleType ......................................................................................................................................................40
getUnitDoubleValue.....................................................................................................................................................40
hasKey................................................................................................................................................................................40
isEqual................................................................................................................................................................................40
putBoolean ......................................................................................................................................................................40
putClass.............................................................................................................................................................................40
putData .............................................................................................................................................................................40
3
Adobe Photoshop CS4
JavaScript Scripting Reference 4
putDouble ........................................................................................................................................................................40
putEnumerated ..............................................................................................................................................................40
putInteger ........................................................................................................................................................................40
putList ................................................................................................................................................................................41
putObject..........................................................................................................................................................................41
putPath..............................................................................................................................................................................41
putReference...................................................................................................................................................................41
putString...........................................................................................................................................................................41
putUnitDouble................................................................................................................................................................41
toStream ...........................................................................................................................................................................41
ActionList.........................................................................................................................................................................................42
Properties..................................................................................................................................................................................42
count ..................................................................................................................................................................................42
typename .........................................................................................................................................................................42
Methods ....................................................................................................................................................................................42
clear ....................................................................................................................................................................................42
getBoolean.......................................................................................................................................................................42
getClass .............................................................................................................................................................................42
getData..............................................................................................................................................................................42
getDouble ........................................................................................................................................................................42
getEnumerationType ...................................................................................................................................................42
getEnumerationValue..................................................................................................................................................42
getInteger.........................................................................................................................................................................42
getList ................................................................................................................................................................................43
getObjectType................................................................................................................................................................43
getObjectValue...............................................................................................................................................................43
getPath ..............................................................................................................................................................................43
getReference ...................................................................................................................................................................43
getString ...........................................................................................................................................................................43
getType .............................................................................................................................................................................43
getUnitDoubleType ......................................................................................................................................................43
getUnitDoubleValue.....................................................................................................................................................43
putBoolean ......................................................................................................................................................................43
putClass.............................................................................................................................................................................43
putData .............................................................................................................................................................................43
putDouble ........................................................................................................................................................................43
putEnumerated ..............................................................................................................................................................43
putInteger ........................................................................................................................................................................43
putList ................................................................................................................................................................................43
putObject..........................................................................................................................................................................43
putPath..............................................................................................................................................................................43
putReference...................................................................................................................................................................43
putString...........................................................................................................................................................................44
putUnitDouble................................................................................................................................................................44
ActionReference ...........................................................................................................................................................................45
Properties..................................................................................................................................................................................45
typename .........................................................................................................................................................................45
Methods ....................................................................................................................................................................................45
getContainer ...................................................................................................................................................................45
getDesiredClass..............................................................................................................................................................45
getEnumeratedType..............................................................................................................
.......................................45
Adobe Photoshop CS4
JavaScript Scripting Reference 5
getEnumeratedValue ...................................................................................................................................................45
getForm.............................................................................................................................................................................45
getIdentifier.....................................................................................................................................................................45
getIndex............................................................................................................................................................................45
getName ...........................................................................................................................................................................45
getOffset ...........................................................................................................................................................................45
getProperty......................................................................................................................................................................45
putClass.............................................................................................................................................................................46
putEnumerated ..............................................................................................................................................................46
putIdentifier.....................................................................................................................................................................46
putIndex............................................................................................................................................................................46
putName ...........................................................................................................................................................................46
putOffset...........................................................................................................................................................................46
putProperty......................................................................................................................................................................46
Application .....................................................................................................................................................................................47
Properties..................................................................................................................................................................................47
activeDocument.............................................................................................................................................................47
backgroundColor...........................................................................................................................................................47
build....................................................................................................................................................................................47
colorSettings ...................................................................................................................................................................47
displayDialogs.................................................................................................................................................................47
documents .......................................................................................................................................................................47
fonts....................................................................................................................................................................................47
foregroundColor ............................................................................................................................................................47
freeMemory .....................................................................................................................................................................47
locale ..................................................................................................................................................................................48
macintoshFileTypes......................................................................................................................................................48
measurementLog ..........................................................................................................................................................48
name...................................................................................................................................................................................48
notifiers .............................................................................................................................................................................48
notifiersEnabled .............................................................................................................................................................48
path.....................................................................................................................................................................................48
playbackDisplayDialogs ..............................................................................................................................................48
playbackParameters .....................................................................................................................................................48
preferences ......................................................................................................................................................................48
preferencesFolder .........................................................................................................................................................48
recentFiles ........................................................................................................................................................................48
scriptingBuildDate ........................................................................................................................................................48
scriptingVersion .............................................................................................................................................................48
systemInformation........................................................................................................................................................48
typename .........................................................................................................................................................................48
version ...............................................................................................................................................................................49
windowsFileTypes.........................................................................................................................................................49
Methods ....................................................................................................................................................................................49
batch ..................................................................................................................................................................................49
beep....................................................................................................................................................................................49
bringToFront ...................................................................................................................................................................49
charIDToTypeID..............................................................................................................................................................49
doAction ...........................................................................................................................................................................49
eraseCustomOptions....................................................................................................................................................49
executeAction..................................................................................................................
...............................................49
Adobe Photoshop CS4
JavaScript Scripting Reference 6
executeActionGet..........................................................................................................................................................49
featureEnabled ...............................................................................................................................................................49
getCustomOptions........................................................................................................................................................50
load .....................................................................................................................................................................................50
makeContactSheet........................................................................................................................................................50
makePDFPresentation .................................................................................................................................................50
makePhotoGallery.........................................................................................................................................................50
makePhotomerge..........................................................................................................................................................50
makePicturePackage....................................................................................................................................................50
open ...................................................................................................................................................................................51
openDialog ......................................................................................................................................................................51
purge..................................................................................................................................................................................51
putCustomOptions .......................................................................................................................................................51
refresh................................................................................................................................................................................51
runMenuItem ..................................................................................................................................................................51
stringIDToTypeID...........................................................................................................................................................51
togglePalettes.................................................................................................................................................................52
typeIDToCharID..............................................................................................................................................................52
typeIDToStringID ...........................................................................................................................................................52
ArtLayer............................................................................................................................................................................................54
Properties..................................................................................................................................................................................54
allLocked...........................................................................................................................................................................54
blendMode.......................................................................................................................................................................54
bounds...............................................................................................................................................................................54
fillOpacity..........................................................................................................................................................................54
filterMaskDensity ...........................................................................................................................................................54
filterMaskFeather...........................................................................................................................................................54
grouped ............................................................................................................................................................................54
isBackgroundLayer........................................................................................................................................................54
kind .....................................................................................................................................................................................54
layerMaskDensity...........................................................................................................................................................54
layerMaskFeather ..........................................................................................................................................................55
linkedLayers.....................................................................................................................................................................55
name...................................................................................................................................................................................55
opacity ...............................................................................................................................................................................55
parent.................................................................................................................................................................................55
pixelsLocked....................................................................................................................................................................55
positionLocked...............................................................................................................................................................55
textItem.............................................................................................................................................................................55
transparentPixelsLocked.............................................................................................................................................55
typename .........................................................................................................................................................................55
vectorMaskDensity........................................................................................................................................................55
vectorMaskFeather .......................................................................................................................................................55
visible .................................................................................................................................................................................55
xmpMetadata..................................................................................................................................................................55
Methods ....................................................................................................................................................................................56
adjustBrightnessContrast ...........................................................................................................................................56
adjustColorBalance .......................................................................................................................................................56
adjustCurves....................................................................................................................................................................56
adjustLevels .....................................................................................................................................................................56
applyAddNoise..................................................................................................................
.............................................56
Adobe Photoshop CS4
JavaScript Scripting Reference 7
applyAverage..................................................................................................................................................................56
applyBlur...........................................................................................................................................................................56
applyBlurMore ................................................................................................................................................................56
applyClouds.....................................................................................................................................................................56
applyCustomFilter.........................................................................................................................................................56
applyDeInterlace............................................................................................................................................................57
applyDespeckle..............................................................................................................................................................57
applyDifferenceClouds................................................................................................................................................57
applyDiffuseGlow ..........................................................................................................................................................57
applyDisplace..................................................................................................................................................................57
applyDustAndScratches..............................................................................................................................................57
applyGaussianBlur.........................................................................................................................................................57
applyGlassEffect.............................................................................................................................................................57
applyHighPass ................................................................................................................................................................57
applyLensBlur .................................................................................................................................................................58
applyLensFlare................................................................................................................................................................58
applyMaximum ..............................................................................................................................................................58
applyMedianNoise ........................................................................................................................................................58
applyMinimum ...............................................................................................................................................................59
applyMotionBlur ............................................................................................................................................................59
applyNTSC........................................................................................................................................................................59
applyOceanRipple.........................................................................................................................................................59
applyOffset.......................................................................................................................................................................59
applyPinch .......................................................................................................................................................................59
applyPolarCoordinates................................................................................................................................................59
applyRadialBlur ..............................................................................................................................................................59
applyRipple......................................................................................................................................................................59
applySharpen..................................................................................................................................................................59
applySharpenEdges......................................................................................................................................................59
applySharpenMore .......................................................................................................................................................59
applyShear .......................................................................................................................................................................59
applySmartBlur...............................................................................................................................................................60
applySpherize .................................................................................................................................................................60
applyStyle.........................................................................................................................................................................60
applyTextureFill..............................................................................................................................................................60
applyTwirl.........................................................................................................................................................................60
applyUnSharpMask.......................................................................................................................................................60
applyWave........................................................................................................................................................................60
applyZigZag.....................................................................................................................................................................60
autoContrast....................................................................................................................................................................60
autoLevels ........................................................................................................................................................................60
clear ....................................................................................................................................................................................60
copy ....................................................................................................................................................................................61
cut........................................................................................................................................................................................61
desaturate ........................................................................................................................................................................61
duplicate ...........................................................................................................................................................................61
equalize .............................................................................................................................................................................61
invert ..................................................................................................................................................................................61
link.......................................................................................................................................................................................61
merge.................................................................................................................................................................................61
mixChannels....................................................................................................................
................................................62
Adobe Photoshop CS4
JavaScript Scripting Reference 8
move...................................................................................................................................................................................62
photoFilter .......................................................................................................................................................................62
posterize ...........................................................................................................................................................................62
rasterize.............................................................................................................................................................................62
remove...............................................................................................................................................................................62
resize ..................................................................................................................................................................................63
rotate..................................................................................................................................................................................63
selectiveColor..................................................................................................................................................................63
shadowHighlight ...........................................................................................................................................................63
threshold...........................................................................................................................................................................63
translate ............................................................................................................................................................................63
unlink .................................................................................................................................................................................63
ArtLayers..........................................................................................................................................................................................66
Properties..................................................................................................................................................................................66
length.................................................................................................................................................................................66
parent.................................................................................................................................................................................66
typename .........................................................................................................................................................................66
Methods ....................................................................................................................................................................................66
add ......................................................................................................................................................................................66
getByName ......................................................................................................................................................................66
removeAll .........................................................................................................................................................................66
BatchOptions .................................................................................................................................................................................67
Properties..................................................................................................................................................................................67
destination .......................................................................................................................................................................67
destinationFolder ..........................................................................................................................................................67
errorFile .............................................................................................................................................................................67
fileNaming........................................................................................................................................................................67
macintoshCompatible .................................................................................................................................................67
overrideOpen..................................................................................................................................................................67
overrideSave....................................................................................................................................................................67
startingSerial ...................................................................................................................................................................67
suppressOpen.................................................................................................................................................................67
suppressProfile ...............................................................................................................................................................68
typename .........................................................................................................................................................................68
unixCompatible..............................................................................................................................................................68
windowsCompatible ....................................................................................................................................................68
BitmapConversionOptions .......................................................................................................................................................69
Properties..................................................................................................................................................................................69
angle...................................................................................................................................................................................69
frequency..........................................................................................................................................................................69
method..............................................................................................................................................................................69
patternName ...................................................................................................................................................................69
resolution..........................................................................................................................................................................69
shape..................................................................................................................................................................................69
typename .........................................................................................................................................................................69
BMPSaveOptions ..........................................................................................................................................................................70
Properties..................................................................................................................................................................................70
alphaChannels................................................................................................................................................................70
depth..................................................................................................................................................................................70
flipRowOrder ...................................................................................................................................................................70
osType.........................................................................................................................
.......................................................70
Adobe Photoshop CS4
JavaScript Scripting Reference 9
rleCompression ..............................................................................................................................................................70
typename .........................................................................................................................................................................70
CameraRAWOpenOptions ........................................................................................................................................................71
Properties..................................................................................................................................................................................71
bitsPerChannel ...............................................................................................................................................................71
blueHue.............................................................................................................................................................................71
blueSaturation ................................................................................................................................................................71
brightness.........................................................................................................................................................................71
chromaticAberrationBY...............................................................................................................................................71
chromaticAberrationRC...............................................................................................................................................71
colorNoiseReduction....................................................................................................................................................71
colorSpace........................................................................................................................................................................71
contrast .............................................................................................................................................................................71
exposure ...........................................................................................................................................................................71
greenHue..........................................................................................................................................................................71
greenSaturation .............................................................................................................................................................71
luminanceSmoothing ..................................................................................................................................................71
redHue...............................................................................................................................................................................71
redSaturation ..................................................................................................................................................................71
resolution..........................................................................................................................................................................71
saturation .........................................................................................................................................................................71
settings..............................................................................................................................................................................71
shadows ............................................................................................................................................................................71
shadowTint ......................................................................................................................................................................71
sharpness..........................................................................................................................................................................71
size ......................................................................................................................................................................................71
temperature.....................................................................................................................................................................71
tint.......................................................................................................................................................................................72
typename .........................................................................................................................................................................72
vignettingAmount ........................................................................................................................................................72
vignettingMidpoint ......................................................................................................................................................72
whiteBalance...................................................................................................................................................................72
Channel............................................................................................................................................................................................73
Properties..................................................................................................................................................................................73
color....................................................................................................................................................................................73
histogram .........................................................................................................................................................................73
kind .....................................................................................................................................................................................73
name...................................................................................................................................................................................73
opacity ...............................................................................................................................................................................73
parent.................................................................................................................................................................................73
typename .........................................................................................................................................................................73
visible .................................................................................................................................................................................73
Methods ....................................................................................................................................................................................73
duplicate ...........................................................................................................................................................................73
merge.................................................................................................................................................................................74
remove...............................................................................................................................................................................74
Channels..........................................................................................................................................................................................75
Properties..................................................................................................................................................................................75
length.................................................................................................................................................................................75
parent.................................................................................................................................................................................75
typename .......................................................................................................................
..................................................75
Adobe Photoshop CS4
JavaScript Scripting Reference 10
Methods ....................................................................................................................................................................................75
add ......................................................................................................................................................................................75
getByName ......................................................................................................................................................................75
removeAll .........................................................................................................................................................................75
CMYKColor......................................................................................................................................................................................80
Properties..................................................................................................................................................................................80
black ...................................................................................................................................................................................80
cyan.....................................................................................................................................................................................80
magenta............................................................................................................................................................................80
typename .........................................................................................................................................................................80
yellow.................................................................................................................................................................................80
ColorSampler .................................................................................................................................................................................81
Properties..................................................................................................................................................................................81
color....................................................................................................................................................................................81
position .............................................................................................................................................................................81
parent.................................................................................................................................................................................81
typename .........................................................................................................................................................................81
Methods ....................................................................................................................................................................................81
move...................................................................................................................................................................................81
remove...............................................................................................................................................................................81
ColorSamplers ...............................................................................................................................................................................82
Properties..................................................................................................................................................................................82
length.................................................................................................................................................................................82
parent.................................................................................................................................................................................82
typename .........................................................................................................................................................................82
Methods ....................................................................................................................................................................................82
add ......................................................................................................................................................................................82
removeAll .........................................................................................................................................................................82
ContactSheetOptions .................................................................................................................................................................83
Properties..................................................................................................................................................................................83
acrossFirst.........................................................................................................................................................................83
bestFit ................................................................................................................................................................................83
caption...............................................................................................................................................................................83
columnCount ..................................................................................................................................................................83
flatten.................................................................................................................................................................................83
font......................................................................................................................................................................................83
fontSize..............................................................................................................................................................................83
height.................................................................................................................................................................................83
horizontal .........................................................................................................................................................................83
mode ..................................................................................................................................................................................83
resolution..........................................................................................................................................................................83
rowCount..........................................................................................................................................................................83
typename .........................................................................................................................................................................83
useAutoSpacing.............................................................................................................................................................83
vertical ...............................................................................................................................................................................83
width ..................................................................................................................................................................................83
CountItem .......................................................................................................................................................................................84
Properties..................................................................................................................................................................................84
position .............................................................................................................................................................................84
parent.................................................................................................................................................................................84
typename .......................................................................................................................
..................................................84
Adobe Photoshop CS4
JavaScript Scripting Reference 11
Methods ....................................................................................................................................................................................84
remove...............................................................................................................................................................................84
CountItems .....................................................................................................................................................................................85
Properties..................................................................................................................................................................................85
length.................................................................................................................................................................................85
parent.................................................................................................................................................................................85
typename .........................................................................................................................................................................85
Methods ....................................................................................................................................................................................85
add ......................................................................................................................................................................................85
getByName ......................................................................................................................................................................85
removeAll .........................................................................................................................................................................85
DCS1_SaveOptions......................................................................................................................................................................86
Properties..................................................................................................................................................................................86
dCS......................................................................................................................................................................................86
embedColorProfile........................................................................................................................................................86
encoding...........................................................................................................................................................................86
halftoneScreen ...............................................................................................................................................................86
interpolation....................................................................................................................................................................86
preview..............................................................................................................................................................................86
transferFunction.............................................................................................................................................................86
typename .........................................................................................................................................................................86
vectorData........................................................................................................................................................................86
DCS2_SaveOptions......................................................................................................................................................................87
Properties..................................................................................................................................................................................87
dCS......................................................................................................................................................................................87
embedColorProfile........................................................................................................................................................87
encoding...........................................................................................................................................................................87
halftoneScreen ...............................................................................................................................................................87
interpolation....................................................................................................................................................................87
multiFileDCS....................................................................................................................................................................87
preview..............................................................................................................................................................................87
spotColors ........................................................................................................................................................................87
transferFunction.............................................................................................................................................................87
typename .........................................................................................................................................................................87
vectorData........................................................................................................................................................................87
DICOMOpenOptions ...................................................................................................................................................................88
Properties..................................................................................................................................................................................88
anonymize........................................................................................................................................................................88
columns.............................................................................................................................................................................88
reverse ...............................................................................................................................................................................88
rows ....................................................................................................................................................................................88
showOverlays..................................................................................................................................................................88
typename .........................................................................................................................................................................88
windowLevel ...................................................................................................................................................................88
windowWidth .................................................................................................................................................................88
Document .......................................................................................................................................................................................89
Properties..................................................................................................................................................................................89
activeChannels ...............................................................................................................................................................89
activeHistoryBrushSource ..........................................................................................................................................89
activeHistoryState .........................................................................................................................................................89
activeLayer ....................................................................................................................
...................................................89
Adobe Photoshop CS4
JavaScript Scripting Reference 12
artLayers............................................................................................................................................................................89
backgroundLayer...........................................................................................................................................................89
bitsPerChannel ...............................................................................................................................................................89
channels............................................................................................................................................................................89
colorProfileName...........................................................................................................................................................89
colorProfileType .............................................................................................................................................................89
colorSamplers .................................................................................................................................................................89
componentChannels....................................................................................................................................................89
countItems .......................................................................................................................................................................90
fullName............................................................................................................................................................................90
height.................................................................................................................................................................................90
histogram .........................................................................................................................................................................90
historyStates....................................................................................................................................................................90
info ......................................................................................................................................................................................90
layerComps ......................................................................................................................................................................90
layers ..................................................................................................................................................................................90
layerSets............................................................................................................................................................................90
managed...........................................................................................................................................................................90
measurementScale .......................................................................................................................................................90
mode ..................................................................................................................................................................................90
name...................................................................................................................................................................................90
parent.................................................................................................................................................................................90
path.....................................................................................................................................................................................90
pathItems .........................................................................................................................................................................90
pixelAspectRatio ............................................................................................................................................................90
printSettings....................................................................................................................................................................90
quickMaskMode .............................................................................................................................................................90
resolution..........................................................................................................................................................................91
saved ..................................................................................................................................................................................91
selection............................................................................................................................................................................91
typename .........................................................................................................................................................................91
width ..................................................................................................................................................................................91
xmpMetadata..................................................................................................................................................................91
Methods ....................................................................................................................................................................................92
autoCount ........................................................................................................................................................................92
changeMode ...................................................................................................................................................................92
close....................................................................................................................................................................................92
convertProfile..................................................................................................................................................................92
crop.....................................................................................................................................................................................92
duplicate ...........................................................................................................................................................................92
exportDocument ...........................................................................................................................................................93
flatten.................................................................................................................................................................................93
flipCanvas .........................................................................................................................................................................93
importAnnotations .......................................................................................................................................................93
mergeVisibleLayers.......................................................................................................................................................93
paste...................................................................................................................................................................................93
print ....................................................................................................................................................................................93
printOneCopy .................................................................................................................................................................93
rasterizeAllLayers...........................................................................................................................................................93
recordMeasurements...................................................................................................................................................93
resizeCanvas...................................................................................................................
.................................................93
Adobe Photoshop CS4
JavaScript Scripting Reference 13
resizeImage......................................................................................................................................................................93
revealAll.............................................................................................................................................................................94
rotateCanvas ...................................................................................................................................................................94
save.....................................................................................................................................................................................94
saveAs ................................................................................................................................................................................94
splitChannels...................................................................................................................................................................94
suspendHistory...............................................................................................................................................................94
trap......................................................................................................................................................................................94
trim......................................................................................................................................................................................94
DocumentPrintSettings .............................................................................................................................................................97
Properties..................................................................................................................................................................................97
backgroundColor...........................................................................................................................................................97
bleedWidth ......................................................................................................................................................................97
caption...............................................................................................................................................................................97
centerCropMarks ...........................................................................................................................................................97
colorBars ...........................................................................................................................................................................97
copies.................................................................................................................................................................................97
cornerCropMarks ...........................................................................................................................................................97
colorHandling .................................................................................................................................................................97
activePrinter ....................................................................................................................................................................97
flip........................................................................................................................................................................................97
hardProof..........................................................................................................................................................................97
interpolate........................................................................................................................................................................97
labels ..................................................................................................................................................................................97
mapBlack ..........................................................................................................................................................................97
negative ............................................................................................................................................................................97
renderIntent ....................................................................................................................................................................97
posX....................................................................................................................................................................................97
posY....................................................................................................................................................................................97
printBorder.......................................................................................................................................................................97
printSelected...................................................................................................................................................................97
printSpace ........................................................................................................................................................................97
registrationMarks...........................................................................................................................................................98
scale....................................................................................................................................................................................98
vectorData........................................................................................................................................................................98
Methods ....................................................................................................................................................................................99
setPagePosition..............................................................................................................................................................99
DocumentInfo ............................................................................................................................................................................ 100
Properties............................................................................................................................................................................... 100
author ............................................................................................................................................................................. 100
authorPosition ............................................................................................................................................................. 100
caption............................................................................................................................................................................ 100
captionWriter ............................................................................................................................................................... 100
category ......................................................................................................................................................................... 100
city.................................................................................................................................................................................... 100
copyrighted .................................................................................................................................................................. 100
copyrightNotice .......................................................................................................................................................... 100
country ........................................................................................................................................................................... 100
creationDate................................................................................................................................................................. 100
credit ............................................................................................................................................................................... 100
exif...........................................................................................................................
......................................................... 100
Adobe Photoshop CS4
JavaScript Scripting Reference 14
headline ......................................................................................................................................................................... 100
instructions ................................................................................................................................................................... 100
jobName ........................................................................................................................................................................ 100
keywords........................................................................................................................................................................ 100
ownerUrl ........................................................................................................................................................................ 100
parent.............................................................................................................................................................................. 101
provinceState............................................................................................................................................................... 101
source.............................................................................................................................................................................. 101
supplementalCategories.......................................................................................................................................... 101
title ................................................................................................................................................................................... 101
transmissionReference ............................................................................................................................................. 101
typename ...................................................................................................................................................................... 101
urgency .......................................................................................................................................................................... 101
Documents .................................................................................................................................................................................. 103
Properties............................................................................................................................................................................... 103
length.............................................................................................................................................................................. 103
parent.............................................................................................................................................................................. 103
typename ...................................................................................................................................................................... 103
Methods ................................................................................................................................................................................. 103
add ................................................................................................................................................................................... 103
getByName ................................................................................................................................................................... 103
EPSOpenOptions ....................................................................................................................................................................... 104
Properties............................................................................................................................................................................... 104
antiAlias.......................................................................................................................................................................... 104
constrainProportions ................................................................................................................................................ 104
height.............................................................................................................................................................................. 104
mode ............................................................................................................................................................................... 104
resolution....................................................................................................................................................................... 104
typename ...................................................................................................................................................................... 104
width ............................................................................................................................................................................... 104
EPSSaveOptions......................................................................................................................................................................... 105
Properties............................................................................................................................................................................... 105
embedColorProfile..................................................................................................................................................... 105
encoding........................................................................................................................................................................ 105
halftoneScreen ............................................................................................................................................................ 105
interpolation................................................................................................................................................................. 105
preview........................................................................................................................................................................... 105
psColorManagement ................................................................................................................................................ 105
transferFunction.......................................................................................................................................................... 105
transparentWhites...................................................................................................................................................... 105
typename ...................................................................................................................................................................... 105
vectorData..................................................................................................................................................................... 105
ExportOptionsIllustrator ......................................................................................................................................................... 106
Properties............................................................................................................................................................................... 106
path.................................................................................................................................................................................. 106
pathName...................................................................................................................................................................... 106
typename ...................................................................................................................................................................... 106
ExportOptionsSaveForWeb ................................................................................................................................................... 107
Properties............................................................................................................................................................................... 107
blur................................................................................................................................................................................... 107
colorReduction .................................................................................................................
........................................... 107
Adobe Photoshop CS4
JavaScript Scripting Reference 15
colors............................................................................................................................................................................... 107
dither............................................................................................................................................................................... 107
ditherAmount .............................................................................................................................................................. 107
format ............................................................................................................................................................................. 107
includeProfile ............................................................................................................................................................... 107
interlaced....................................................................................................................................................................... 107
lossy ................................................................................................................................................................................. 107
matteColor .................................................................................................................................................................... 107
optimized ...................................................................................................................................................................... 107
PNG8................................................................................................................................................................................ 107
quality ............................................................................................................................................................................. 108
transparency................................................................................................................................................................. 108
transparencyAmount ................................................................................................................................................ 108
transparencyDither .................................................................................................................................................... 108
typename ...................................................................................................................................................................... 108
webSnap ........................................................................................................................................................................ 108
File................................................................................................................................................................................................... 109
Folder............................................................................................................................................................................................. 109
GalleryBannerOptions ............................................................................................................................................................. 110
Properties............................................................................................................................................................................... 110
contactInfo.................................................................................................................................................................... 110
date.................................................................................................................................................................................. 110
font................................................................................................................................................................................... 110
fontSize........................................................................................................................................................................... 110
photographer............................................................................................................................................................... 110
siteName........................................................................................................................................................................ 110
typename ...................................................................................................................................................................... 110
GalleryCustomColorOptions ................................................................................................................................................. 111
Properties............................................................................................................................................................................... 111
activeLinkColor............................................................................................................................................................ 111
backgroundColor........................................................................................................................................................ 111
bannerColor.................................................................................................................................................................. 111
linkColor......................................................................................................................................................................... 111
textColor ........................................................................................................................................................................ 111
typename ...................................................................................................................................................................... 111
visitedLinkColor........................................................................................................................................................... 111
GalleryImagesOptions ............................................................................................................................................................. 112
Properties............................................................................................................................................................................... 112
border ............................................................................................................................................................................. 112
caption............................................................................................................................................................................ 112
dimension...................................................................................................................................................................... 112
font................................................................................................................................................................................... 112
fontSize........................................................................................................................................................................... 112
imageQuality................................................................................................................................................................ 112
includeCopyright........................................................................................................................................................ 112
includeCredits.............................................................................................................................................................. 112
includeFilename.......................................................................................................................................................... 112
includeTitle ................................................................................................................................................................... 112
numericLinks................................................................................................................................................................ 112
resizeConstraint .......................................................................................................................................................... 113
resizeImages...................................................................................................................
.............................................. 113
Adobe Photoshop CS4
JavaScript Scripting Reference 16
typename ...................................................................................................................................................................... 113
GalleryOptions............................................................................................................................................................................ 114
Properties............................................................................................................................................................................... 114
addSizeAttributes ....................................................................................................................................................... 114
bannerOptions ............................................................................................................................................................ 114
customColorOptions ................................................................................................................................................. 114
emailAddress................................................................................................................................................................ 114
imagesOptions ............................................................................................................................................................ 114
includeSubFolders ..................................................................................................................................................... 114
layoutStyle .................................................................................................................................................................... 114
preserveAllMetadata ................................................................................................................................................. 114
securityOptions ........................................................................................................................................................... 114
thumbnailOptions...................................................................................................................................................... 114
typename ...................................................................................................................................................................... 114
useShortExtension ..................................................................................................................................................... 114
useUTF8Encoding ...................................................................................................................................................... 114
GallerySecurityOptions ........................................................................................................................................................... 115
Properties............................................................................................................................................................................... 115
content ........................................................................................................................................................................... 115
font................................................................................................................................................................................... 115
fontSize........................................................................................................................................................................... 115
opacity ............................................................................................................................................................................ 115
text ................................................................................................................................................................................... 115
textColor ........................................................................................................................................................................ 115
textPosition................................................................................................................................................................... 115
textRotate...................................................................................................................................................................... 115
typename ...................................................................................................................................................................... 115
GalleryThumbnailOptions...................................................................................................................................................... 116
Properties............................................................................................................................................................................... 116
border ............................................................................................................................................................................. 116
caption............................................................................................................................................................................ 116
columnCount ............................................................................................................................................................... 116
dimension...................................................................................................................................................................... 116
font................................................................................................................................................................................... 116
fontSize........................................................................................................................................................................... 116
includeCopyright........................................................................................................................................................ 116
includeCredits.............................................................................................................................................................. 116
includeFilename.......................................................................................................................................................... 116
includeTitle ................................................................................................................................................................... 116
rowCount....................................................................................................................................................................... 116
size ................................................................................................................................................................................... 116
typename ...................................................................................................................................................................... 116
GIFSaveOptions.......................................................................................................................................................................... 117
Properties............................................................................................................................................................................... 117
colors............................................................................................................................................................................... 117
dither............................................................................................................................................................................... 117
ditherAmount .............................................................................................................................................................. 117
forced.............................................................................................................................................................................. 117
interlaced....................................................................................................................................................................... 117
matte............................................................................................................................................................................... 117
palette........................................................................................................................
..................................................... 117
Adobe Photoshop CS4
JavaScript Scripting Reference 17
preserveExactColors .................................................................................................................................................. 117
transparency................................................................................................................................................................. 117
typename ...................................................................................................................................................................... 117
GrayColor...................................................................................................................................................................................... 118
Properties............................................................................................................................................................................... 118
gray .................................................................................................................................................................................. 118
typename ...................................................................................................................................................................... 118
HistoryState ................................................................................................................................................................................. 119
Properties............................................................................................................................................................................... 119
name................................................................................................................................................................................ 119
parent.............................................................................................................................................................................. 119
snapshot ........................................................................................................................................................................ 119
typename ...................................................................................................................................................................... 119
HistoryStates ............................................................................................................................................................................... 120
Properties............................................................................................................................................................................... 120
length.............................................................................................................................................................................. 120
parent.............................................................................................................................................................................. 120
typename ...................................................................................................................................................................... 120
Methods ................................................................................................................................................................................. 120
getByName ................................................................................................................................................................... 120
HSBColor....................................................................................................................................................................................... 121
Properties............................................................................................................................................................................... 121
brightness...................................................................................................................................................................... 121
hue ................................................................................................................................................................................... 121
saturation ...................................................................................................................................................................... 121
typename ...................................................................................................................................................................... 121
IndexedConversionOptions .................................................................................................................................................. 122
Properties............................................................................................................................................................................... 122
colors............................................................................................................................................................................... 122
dither............................................................................................................................................................................... 122
ditherAmount .............................................................................................................................................................. 122
forced.............................................................................................................................................................................. 122
matte............................................................................................................................................................................... 122
palette............................................................................................................................................................................. 122
preserveExactColors .................................................................................................................................................. 122
transparency................................................................................................................................................................. 122
typename ...................................................................................................................................................................... 122
JPEGSaveOptions ...................................................................................................................................................................... 123
Properties............................................................................................................................................................................... 123
embedColorProfile..................................................................................................................................................... 123
formatOptions ............................................................................................................................................................. 123
matte............................................................................................................................................................................... 123
quality ............................................................................................................................................................................. 123
scans................................................................................................................................................................................ 123
typename ...................................................................................................................................................................... 123
LabColor ....................................................................................................................................................................................... 124
Properties............................................................................................................................................................................... 124
a......................................................................................................................................................................................... 124
b ........................................................................................................................................................................................ 124
l.......................................................................................................................................................................................... 124
typename .......................................................................................................................
............................................... 124
Adobe Photoshop CS4
JavaScript Scripting Reference 18
LayerComp................................................................................................................................................................................... 125
Properties............................................................................................................................................................................... 125
appearance ................................................................................................................................................................... 125
comment ....................................................................................................................................................................... 125
name................................................................................................................................................................................ 125
parent.............................................................................................................................................................................. 125
position .......................................................................................................................................................................... 125
selected .......................................................................................................................................................................... 125
typename ...................................................................................................................................................................... 125
visibility .......................................................................................................................................................................... 125
Methods ................................................................................................................................................................................. 125
apply................................................................................................................................................................................ 125
recapture ....................................................................................................................................................................... 125
remove............................................................................................................................................................................ 125
resetfromComp ........................................................................................................................................................... 125
LayerComps................................................................................................................................................................................. 126
Properties............................................................................................................................................................................... 126
length.............................................................................................................................................................................. 126
parent.............................................................................................................................................................................. 126
typename ...................................................................................................................................................................... 126
Methods ................................................................................................................................................................................. 126
add ................................................................................................................................................................................... 126
getByName ................................................................................................................................................................... 126
removeAll ...................................................................................................................................................................... 126
Layers............................................................................................................................................................................................. 127
Properties............................................................................................................................................................................... 127
length.............................................................................................................................................................................. 127
parent.............................................................................................................................................................................. 127
typename ...................................................................................................................................................................... 127
Methods ................................................................................................................................................................................. 127
getByName ................................................................................................................................................................... 127
removeAll ...................................................................................................................................................................... 127
LayerSet ........................................................................................................................................................................................ 128
Properties............................................................................................................................................................................... 128
allLocked........................................................................................................................................................................ 128
artLayers......................................................................................................................................................................... 128
blendMode.................................................................................................................................................................... 128
bounds............................................................................................................................................................................ 128
enabledChannels........................................................................................................................................................ 128
layers ............................................................................................................................................................................... 128
layerSets......................................................................................................................................................................... 128
linkedLayers.................................................................................................................................................................. 128
name................................................................................................................................................................................ 128
opacity ............................................................................................................................................................................ 128
parent.............................................................................................................................................................................. 128
typename ...................................................................................................................................................................... 128
visible .............................................................................................................................................................................. 128
Methods ................................................................................................................................................................................. 129
duplicate ........................................................................................................................................................................ 129
link.................................................................................................................................................................................... 129
merge..........................................................................................................................
.................................................... 129
Adobe Photoshop CS4
JavaScript Scripting Reference 19
move................................................................................................................................................................................ 129
remove............................................................................................................................................................................ 129
resize ............................................................................................................................................................................... 129
rotate............................................................................................................................................................................... 129
translate ......................................................................................................................................................................... 129
unlink .............................................................................................................................................................................. 129
LayerSets ...................................................................................................................................................................................... 130
Properties............................................................................................................................................................................... 130
length.............................................................................................................................................................................. 130
parent.............................................................................................................................................................................. 130
typename ...................................................................................................................................................................... 130
Methods ................................................................................................................................................................................. 130
add ................................................................................................................................................................................... 130
getByName ................................................................................................................................................................... 130
removeAll ...................................................................................................................................................................... 130
MeasurementLog ...................................................................................................................................................................... 132
Methods ................................................................................................................................................................................. 132
exportMeasurements................................................................................................................................................ 132
deleteMeasurements ................................................................................................................................................ 132
MeasurementScale ................................................................................................................................................................... 133
Properties............................................................................................................................................................................... 133
pixelLength................................................................................................................................................................... 133
logicalLength ............................................................................................................................................................... 133
logicalUnits ................................................................................................................................................................... 133
NoColor......................................................................................................................................................................................... 134
Properties............................................................................................................................................................................... 134
typename ...................................................................................................................................................................... 134
Notifier........................................................................................................................................................................................... 135
Properties............................................................................................................................................................................... 135
event................................................................................................................................................................................ 135
eventClass ..................................................................................................................................................................... 135
eventFile ........................................................................................................................................................................ 135
parent.............................................................................................................................................................................. 135
typename ...................................................................................................................................................................... 135
Methods ................................................................................................................................................................................. 135
remove............................................................................................................................................................................ 135
Notifiers......................................................................................................................................................................................... 136
Properties............................................................................................................................................................................... 136
length.............................................................................................................................................................................. 136
parent.............................................................................................................................................................................. 136
typename ...................................................................................................................................................................... 136
Methods ................................................................................................................................................................................. 136
add ................................................................................................................................................................................... 136
removeAll ...................................................................................................................................................................... 136
PathItem ....................................................................................................................................................................................... 137
Properties............................................................................................................................................................................... 137
kind .................................................................................................................................................................................. 137
name................................................................................................................................................................................ 137
parent.............................................................................................................................................................................. 137
subPathItems ............................................................................................................................................................... 137
typename .......................................................................................................................
............................................... 137
Adobe Photoshop CS4
JavaScript Scripting Reference 20
Methods ................................................................................................................................................................................. 137
deselect .......................................................................................................................................................................... 137
duplicate ........................................................................................................................................................................ 137
fillPath............................................................................................................................................................................. 137
makeClippingPath...................................................................................................................................................... 138
makeSelection ............................................................................................................................................................. 138
remove............................................................................................................................................................................ 138
select ............................................................................................................................................................................... 138
strokePath ..................................................................................................................................................................... 138
PathItems ..................................................................................................................................................................................... 141
Properties............................................................................................................................................................................... 141
length.............................................................................................................................................................................. 141
parent.............................................................................................................................................................................. 141
typename ...................................................................................................................................................................... 141
Methods ................................................................................................................................................................................. 141
add ................................................................................................................................................................................... 141
getByName ................................................................................................................................................................... 141
removeAll ...................................................................................................................................................................... 141
PathPoint...................................................................................................................................................................................... 142
Properties............................................................................................................................................................................... 142
anchor............................................................................................................................................................................. 142
kind .................................................................................................................................................................................. 142
leftDirection.................................................................................................................................................................. 142
parent.............................................................................................................................................................................. 142
rightDirection............................................................................................................................................................... 142
typename ...................................................................................................................................................................... 142
PathPointInfo.............................................................................................................................................................................. 143
Properties............................................................................................................................................................................... 143
anchor............................................................................................................................................................................. 143
kind .................................................................................................................................................................................. 143
leftDirection.................................................................................................................................................................. 143
rightDirection............................................................................................................................................................... 143
typename ...................................................................................................................................................................... 143
PathPoints.................................................................................................................................................................................... 145
Properties............................................................................................................................................................................... 145
length.............................................................................................................................................................................. 145
parent.............................................................................................................................................................................. 145
typename ...................................................................................................................................................................... 145
PDFOpenOptions ...................................................................................................................................................................... 146
Properties............................................................................................................................................................................... 146
antiAlias.......................................................................................................................................................................... 146
bitsPerChannel ............................................................................................................................................................ 146
constrainProportions ................................................................................................................................................ 146
cropPage........................................................................................................................................................................ 146
height.............................................................................................................................................................................. 146
mode ............................................................................................................................................................................... 146
name................................................................................................................................................................................ 146
page................................................................................................................................................................................. 146
resolution....................................................................................................................................................................... 146
suppressWarnings...................................................................................................................................................... 146
typename .......................................................................................................................
............................................... 146
Adobe Photoshop CS4
JavaScript Scripting Reference 21
usePageNumber ......................................................................................................................................................... 146
width ............................................................................................................................................................................... 146
PDFSaveOptions ........................................................................................................................................................................ 147
Properties............................................................................................................................................................................... 147
alphaChannels............................................................................................................................................................. 147
annotations................................................................................................................................................................... 147
colorConversion.......................................................................................................................................................... 147
convertToEightBit....................................................................................................................................................... 147
description .................................................................................................................................................................... 147
destinationProfile ....................................................................................................................................................... 147
downgradeColorProfile............................................................................................................................................ 147
downSample ................................................................................................................................................................ 147
downSampleSize ........................................................................................................................................................ 147
downSampleSizeLimit .............................................................................................................................................. 147
embedColorProfile..................................................................................................................................................... 147
embedFonts ................................................................................................................................................................. 147
embedThumbnail....................................................................................................................................................... 147
encoding........................................................................................................................................................................ 147
interpolation................................................................................................................................................................. 147
jpegQuality ................................................................................................................................................................... 148
layers ............................................................................................................................................................................... 148
optimizeForWeb ......................................................................................................................................................... 148
outputCondition ......................................................................................................................................................... 148
outputConditionID..................................................................................................................................................... 148
PDFCompatibility........................................................................................................................................................ 148
PDFStandard ................................................................................................................................................................ 148
preserveEditing ........................................................................................................................................................... 148
presetFile ....................................................................................................................................................................... 148
profileInclusionPolicy................................................................................................................................................ 148
registryName................................................................................................................................................................ 148
spotColors ..................................................................................................................................................................... 148
tileSize............................................................................................................................................................................. 148
transparency................................................................................................................................................................. 148
typename ...................................................................................................................................................................... 148
useOutlines ................................................................................................................................................................... 148
vectorData..................................................................................................................................................................... 149
view.................................................................................................................................................................................. 149
PhotoCDOpenOptions ............................................................................................................................................................ 150
Properties............................................................................................................................................................................... 150
colorProfileName........................................................................................................................................................ 150
colorSpace..................................................................................................................................................................... 150
orientation..................................................................................................................................................................... 150
pixelSize ......................................................................................................................................................................... 150
resolution....................................................................................................................................................................... 150
typename ...................................................................................................................................................................... 150
PhotoshopSaveOptions .......................................................................................................................................................... 151
Properties............................................................................................................................................................................... 151
alphaChannels............................................................................................................................................................. 151
annotations................................................................................................................................................................... 151
embedColorProfile..................................................................................................................................................... 151
layers .........................................................................................................................
...................................................... 151
Adobe Photoshop CS4
JavaScript Scripting Reference 22
spotColors ..................................................................................................................................................................... 151
typename ...................................................................................................................................................................... 151
PICTFileSaveOptions ................................................................................................................................................................ 152
Properties............................................................................................................................................................................... 152
alphaChannels............................................................................................................................................................. 152
compression ................................................................................................................................................................. 152
embedColorProfile..................................................................................................................................................... 152
resolution....................................................................................................................................................................... 152
typename ...................................................................................................................................................................... 152
PICTResourceSaveOptions..................................................................................................................................................... 153
Properties............................................................................................................................................................................... 153
alphaChannels............................................................................................................................................................. 153
compression ................................................................................................................................................................. 153
embedColorProfile..................................................................................................................................................... 153
name................................................................................................................................................................................ 153
resolution....................................................................................................................................................................... 153
resourceID ..................................................................................................................................................................... 153
typename ...................................................................................................................................................................... 153
PicturePackageOptions........................................................................................................................................................... 154
Properties............................................................................................................................................................................... 154
content ........................................................................................................................................................................... 154
flatten.............................................................................................................................................................................. 154
font................................................................................................................................................................................... 154
fontSize........................................................................................................................................................................... 154
layout .............................................................................................................................................................................. 154
mode ............................................................................................................................................................................... 154
opacity ............................................................................................................................................................................ 154
resolution....................................................................................................................................................................... 154
text ................................................................................................................................................................................... 154
textColor ........................................................................................................................................................................ 154
textPosition................................................................................................................................................................... 154
textRotate...................................................................................................................................................................... 154
typename ...................................................................................................................................................................... 154
PixarSaveOptions ...................................................................................................................................................................... 155
Properties............................................................................................................................................................................... 155
alphaChannels............................................................................................................................................................. 155
typename ...................................................................................................................................................................... 155
PNGSaveOptions ....................................................................................................................................................................... 156
Properties............................................................................................................................................................................... 156
interlaced....................................................................................................................................................................... 156
typename ...................................................................................................................................................................... 156
Preferences.................................................................................................................................................................................. 157
Properties............................................................................................................................................................................... 157
additionalPluginFolder............................................................................................................................................. 157
appendExtension........................................................................................................................................................ 157
askBeforeSavingLayeredTIFF.................................................................................................................................. 157
autoUpdateOpenDocuments ................................................................................................................................ 157
beepWhenDone.......................................................................................................................................................... 157
colorChannelsInColor ............................................................................................................................................... 157
colorPicker..................................................................................................................................................................... 157
columnGutter...................................................................................................................
............................................ 157
Adobe Photoshop CS4
JavaScript Scripting Reference 23
columnWidth ............................................................................................................................................................... 157
createFirstSnapshot................................................................................................................................................... 157
dynamicColorSliders.................................................................................................................................................. 157
editLogItems ................................................................................................................................................................ 157
exportClipboard.......................................................................................................................................................... 158
fontPreviewSize........................................................................................................................................................... 158
fullSizePreview............................................................................................................................................................. 158
gamutWarningOpacity............................................................................................................................................. 158
gridSize........................................................................................................................................................................... 158
gridStyle ......................................................................................................................................................................... 158
gridSubDivisions ......................................................................................................................................................... 158
guideStyle...................................................................................................................................................................... 158
iconPreview .................................................................................................................................................................. 158
imageCacheLevels ..................................................................................................................................................... 158
imagePreviews ............................................................................................................................................................ 158
interpolation................................................................................................................................................................. 158
keyboardZoomResizesWindows........................................................................................................................... 158
macOSThumbnail....................................................................................................................................................... 158
maximizeCompatibility ............................................................................................................................................ 158
maxRAMuse.................................................................................................................................................................. 158
nonLinearHistory ........................................................................................................................................................ 158
numberofHistoryStates ............................................................................................................................................ 159
otherCursors................................................................................................................................................................. 159
paintingCursors........................................................................................................................................................... 159
parent.............................................................................................................................................................................. 159
pixelDoubling .............................................................................................................................................................. 159
pointSize ........................................................................................................................................................................ 159
recentFileListLength.................................................................................................................................................. 159
rulerUnits ....................................................................................................................................................................... 159
saveLogItems ............................................................................................................................................................... 159
saveLogItemsFile ........................................................................................................................................................ 159
savePaletteLocations ................................................................................................................................................ 159
showAsianTextOptions ............................................................................................................................................ 159
showEnglishFontNames .......................................................................................................................................... 159
showSliceNumber ...................................................................................................................................................... 159
showToolTips ............................................................................................................................................................... 159
smartQuotes................................................................................................................................................................. 159
typename ...................................................................................................................................................................... 159
typeUnits ....................................................................................................................................................................... 159
useAdditionalPluginFolder ..................................................................................................................................... 160
useHistoryLog .............................................................................................................................................................. 160
useLowerCaseExtension .......................................................................................................................................... 160
useShiftKeyForToolSwitch....................................................................................................................................... 160
useVideoAlpha ............................................................................................................................................................ 160
windowsThumbnail ................................................................................................................................................... 160
PresentationOptions ................................................................................................................................................................ 161
Properties............................................................................................................................................................................... 161
autoAdvance ............................................................................................................................................................... 161
includeFilename.......................................................................................................................................................... 161
interval............................................................................................................................................................................ 161
loop...........................................................................................................................
....................................................... 161
Adobe Photoshop CS4
JavaScript Scripting Reference 24
magnification............................................................................................................................................................... 161
PDFFileOptions............................................................................................................................................................ 161
presentation ................................................................................................................................................................ 161
transition........................................................................................................................................................................ 161
typename ...................................................................................................................................................................... 161
RawFormatOpenOptions ....................................................................................................................................................... 162
Properties............................................................................................................................................................................... 162
bitsPerChannel ............................................................................................................................................................ 162
byteOrder ...................................................................................................................................................................... 162
channelNumber .......................................................................................................................................................... 162
headerSize..................................................................................................................................................................... 162
height.............................................................................................................................................................................. 162
interleaveChannels .................................................................................................................................................... 162
retainHeader................................................................................................................................................................. 162
typename ...................................................................................................................................................................... 162
width ............................................................................................................................................................................... 162
RawSaveOptions........................................................................................................................................................................ 163
Properties............................................................................................................................................................................... 163
alphaChannels............................................................................................................................................................. 163
spotColors ..................................................................................................................................................................... 163
typename ...................................................................................................................................................................... 163
RGBColor....................................................................................................................................................................................... 164
Properties............................................................................................................................................................................... 164
blue.................................................................................................................................................................................. 164
green ............................................................................................................................................................................... 164
hexValue ........................................................................................................................................................................ 164
red .................................................................................................................................................................................... 164
typename ...................................................................................................................................................................... 164
Selection ....................................................................................................................................................................................... 165
Properties............................................................................................................................................................................... 165
bounds............................................................................................................................................................................ 165
parent.............................................................................................................................................................................. 165
solid ................................................................................................................................................................................. 165
typename ...................................................................................................................................................................... 165
Methods ................................................................................................................................................................................. 165
clear ................................................................................................................................................................................. 165
contract .......................................................................................................................................................................... 165
copy ................................................................................................................................................................................. 165
cut..................................................................................................................................................................................... 165
deselect .......................................................................................................................................................................... 165
expand............................................................................................................................................................................ 165
feather............................................................................................................................................................................. 165
fill ...................................................................................................................................................................................... 166
grow ................................................................................................................................................................................ 166
invert ............................................................................................................................................................................... 166
load .................................................................................................................................................................................. 166
makeWorkPath ............................................................................................................................................................ 166
resize ............................................................................................................................................................................... 166
resizeBoundary............................................................................................................................................................ 166
rotate............................................................................................................................................................................... 166
rotateBoundary .................................................................................................................
.......................................... 166
Adobe Photoshop CS4
JavaScript Scripting Reference 25
select ............................................................................................................................................................................... 166
selectAll .......................................................................................................................................................................... 166
fill ...................................................................................................................................................................................... 167
grow ................................................................................................................................................................................ 167
invert ............................................................................................................................................................................... 167
load .................................................................................................................................................................................. 167
makeWorkPath ............................................................................................................................................................ 167
resize ............................................................................................................................................................................... 167
resizeBoundary............................................................................................................................................................ 167
rotate............................................................................................................................................................................... 167
rotateBoundary ........................................................................................................................................................... 167
select ............................................................................................................................................................................... 167
selectAll .......................................................................................................................................................................... 167
fill ...................................................................................................................................................................................... 168
grow ................................................................................................................................................................................ 168
invert ............................................................................................................................................................................... 168
load .................................................................................................................................................................................. 168
makeWorkPath ............................................................................................................................................................ 168
resize ............................................................................................................................................................................... 168
resizeBoundary............................................................................................................................................................ 168
rotate............................................................................................................................................................................... 168
rotateBoundary ........................................................................................................................................................... 168
select ............................................................................................................................................................................... 168
selectAll .......................................................................................................................................................................... 168
selectBorder.................................................................................................................................................................. 169
similar.............................................................................................................................................................................. 169
smooth ........................................................................................................................................................................... 169
store................................................................................................................................................................................. 169
stroke............................................................................................................................................................................... 169
translate ......................................................................................................................................................................... 169
translateBoundary...................................................................................................................................................... 169
SGIRGBSaveOptions ................................................................................................................................................................. 172
Properties............................................................................................................................................................................... 172
alphaChannels............................................................................................................................................................. 172
spotColors ..................................................................................................................................................................... 172
typename ...................................................................................................................................................................... 172
SolidColor..................................................................................................................................................................................... 173
Properties............................................................................................................................................................................... 173
cmyk ................................................................................................................................................................................ 173
gray .................................................................................................................................................................................. 173
hsb.................................................................................................................................................................................... 173
lab..................................................................................................................................................................................... 173
model.............................................................................................................................................................................. 173
nearestWebColor........................................................................................................................................................ 173
rgb.................................................................................................................................................................................... 173
typename ...................................................................................................................................................................... 173
Methods ................................................................................................................................................................................. 173
isEqual............................................................................................................................................................................. 173
SubPathInfo................................................................................................................................................................................. 174
Properties............................................................................................................................................................................... 174
closed.........................................................................................................................
..................................................... 174
Adobe Photoshop CS4
JavaScript Scripting Reference 26
entireSubPath .............................................................................................................................................................. 174
operation ....................................................................................................................................................................... 174
typename ...................................................................................................................................................................... 174
SubPathItem................................................................................................................................................................................ 175
Properties............................................................................................................................................................................... 175
closed.............................................................................................................................................................................. 175
operation ....................................................................................................................................................................... 175
parent.............................................................................................................................................................................. 175
pathPoints ..................................................................................................................................................................... 175
typename ...................................................................................................................................................................... 175
SubPathItems.............................................................................................................................................................................. 176
Properties............................................................................................................................................................................... 176
length.............................................................................................................................................................................. 176
parent.............................................................................................................................................................................. 176
typename ...................................................................................................................................................................... 176
TargaSaveOptions..................................................................................................................................................................... 177
Properties............................................................................................................................................................................... 177
alphaChannels............................................................................................................................................................. 177
resolution....................................................................................................................................................................... 177
rleCompression ........................................................................................................................................................... 177
typename ...................................................................................................................................................................... 177
TextFont........................................................................................................................................................................................ 178
Properties............................................................................................................................................................................... 178
family............................................................................................................................................................................... 178
name................................................................................................................................................................................ 178
parent.............................................................................................................................................................................. 178
postScriptName ......................................................................................................................................................... 178
style.................................................................................................................................................................................. 178
typename ...................................................................................................................................................................... 178
TextFonts...................................................................................................................................................................................... 179
Properties............................................................................................................................................................................... 179
length.............................................................................................................................................................................. 179
parent.............................................................................................................................................................................. 179
typename ...................................................................................................................................................................... 179
Methods ................................................................................................................................................................................. 179
getByName ................................................................................................................................................................... 179
TextItem........................................................................................................................................................................................ 180
Properties............................................................................................................................................................................... 180
alternateLigatures ...................................................................................................................................................... 180
antiAliasMethod.......................................................................................................................................................... 180
autoKerning.................................................................................................................................................................. 180
autoLeadingAmount................................................................................................................................................. 180
baselineShift................................................................................................................................................................. 180
capitalization................................................................................................................................................................ 180
color................................................................................................................................................................................. 180
contents ......................................................................................................................................................................... 180
desiredGlyphScaling.................................................................................................................................................. 180
desiredLetterScaling.................................................................................................................................................. 181
desiredWordScaling .................................................................................................................................................. 181
direction......................................................................................................................................................................... 181
fauxBold .......................................................................................................................
.................................................. 181
Adobe Photoshop CS4
JavaScript Scripting Reference 27
fauxItalic......................................................................................................................................................................... 181
firstLineIndent.............................................................................................................................................................. 181
font................................................................................................................................................................................... 181
hangingPunctuation ................................................................................................................................................. 181
height.............................................................................................................................................................................. 181
horizontalScale ............................................................................................................................................................ 181
hyphenateAfterFirst................................................................................................................................................... 182
hyphenateBeforeLast................................................................................................................................................ 182
hyphenateCapitalWords .......................................................................................................................................... 182
hyphenateWordsLongerThan................................................................................................................................ 182
hyphenation ................................................................................................................................................................. 182
hyphenationZone....................................................................................................................................................... 182
hyphenLimit ................................................................................................................................................................. 182
justification ................................................................................................................................................................... 182
kind .................................................................................................................................................................................. 182
language........................................................................................................................................................................ 182
leading............................................................................................................................................................................ 182
leftIndent ....................................................................................................................................................................... 182
ligatures ......................................................................................................................................................................... 182
maximumGlyphScaling ............................................................................................................................................ 182
maximumLetterScaling ............................................................................................................................................ 183
maximumWordScaling............................................................................................................................................. 183
minimumGlyphScaling............................................................................................................................................. 183
minimumLetterScaling............................................................................................................................................. 184
minimumWordScaling.............................................................................................................................................. 184
noBreak .......................................................................................................................................................................... 184
oldStyle........................................................................................................................................................................... 184
parent.............................................................................................................................................................................. 184
position .......................................................................................................................................................................... 184
rightIndent.................................................................................................................................................................... 184
size ................................................................................................................................................................................... 184
spaceAfter ..................................................................................................................................................................... 184
spaceBefore .................................................................................................................................................................. 185
strikeThru....................................................................................................................................................................... 185
textComposer .............................................................................................................................................................. 185
tracking........................................................................................................................................................................... 185
typename ...................................................................................................................................................................... 185
underline........................................................................................................................................................................ 185
useAutoLeading.......................................................................................................................................................... 185
verticalScale.................................................................................................................................................................. 185
warpBend ...................................................................................................................................................................... 185
warpDirection .............................................................................................................................................................. 185
warpHorizontalDistortion........................................................................................................................................ 185
warpStyle....................................................................................................................................................................... 185
warpVerticalDistortion.............................................................................................................................................. 185
width ............................................................................................................................................................................... 185
Methods ................................................................................................................................................................................. 186
convertToShape.......................................................................................................................................................... 186
createPath ..................................................................................................................................................................... 186
TiffSaveOptions.......................................................................................................................................................................... 187
Properties.....................................................................................................................
.......................................................... 187
Adobe Photoshop CS4
JavaScript Scripting Reference 28
alphaChannels............................................................................................................................................................. 187
annotations................................................................................................................................................................... 187
byteOrder ...................................................................................................................................................................... 187
embedColorProfile..................................................................................................................................................... 187
imageCompression.................................................................................................................................................... 187
interleaveChannels .................................................................................................................................................... 187
jpegQuality ................................................................................................................................................................... 187
layerCompression....................................................................................................................................................... 187
layers ............................................................................................................................................................................... 187
saveImagePyramid..................................................................................................................................................... 187
spotColors ..................................................................................................................................................................... 187
transparency................................................................................................................................................................. 187
typename ...................................................................................................................................................................... 187
UnitValue...................................................................................................................................................................................... 188
xmpMetadata ............................................................................................................................................................................. 189
Properties............................................................................................................................................................................... 189
parent.............................................................................................................................................................................. 189
rawData .......................................................................................................................................................................... 189
typename ...................................................................................................................................................................... 189
3 JavaScript Resource.................................................................................................................190
JavaScript resource syntax..................................................................................................................................................... 190
Basic JavaScript resource example ............................................................................................................................... 191
Enable-info grammar ............................................................................................................................................................... 191
Undefined values in enable-info evaluation ............................................................................................................. 193
Using the "in" function...................................................................................................................................................... 194
Action Manager automation" ............................................................................................................................................... 194
Terminology dictionary .................................................................................................................................................... 194
Value type defintions .................................................................................................................................................. 195
Uniqueness rules for terminology entries.................................................................................................................. 196
Terminology definition example................................................................................................................................... 196
4 Scripting Constants .................................................................................................................198
AdjustmentReference ............................................................................................................................................... 198
AnchorPosition............................................................................................................................................................ 198
AntiAlias ......................................................................................................................................................................... 198
AutoKernType.............................................................................................................................................................. 198
BatchDestinationType .............................................................................................................................................. 198
BitmapConversionType............................................................................................................................................ 199
BitmapHalfToneType ................................................................................................................................................ 199
BitsPerChannelType................................................................................................................................................... 199
BlendMode.................................................................................................................................................................... 199
BMPDepthType ........................................................................................................................................................... 199
ByteOrder ...................................................................................................................................................................... 199
CameraRAWSettingsType........................................................................................................................................ 200
CameraRAWSize.......................................................................................................................................................... 200
ChangeMode................................................................................................................................................................ 200
ChannelType ................................................................................................................................................................ 200
ColorBlendMode......................................................................................................................................................... 201
ColorModel ................................................................................................................................................................... 201
ColorPicker.................................................................................................................................................................... 201
ColorProfileType ......................................................................................................................................................... 201
Adobe Photoshop CS4
JavaScript Scripting Reference 29
ColorReductionType.................................................................................................................................................. 201
ColorSpaceType .......................................................................................................................................................... 201
CopyrightedType........................................................................................................................................................ 201
CreateFields .................................................................................................................................................................. 202
CropToType .................................................................................................................................................................. 202
DCSType......................................................................................................................................................................... 202
DepthMapSource ....................................................................................................................................................... 202
DescValueType ............................................................................................................................................................ 202
DialogModes ................................................................................................................................................................ 202
Direction ........................................................................................................................................................................ 202
DisplacementMapType ............................................................................................................................................ 202
Dither .............................................................................................................................................................................. 203
DocPositionStyle......................................................................................................................................................... 203
DocumentFill................................................................................................................................................................ 203
DocumentMode.......................................................................................................................................................... 203
EditLogItemsType....................................................................................................................................................... 203
ElementPlacement..................................................................................................................................................... 203
EliminateFields ............................................................................................................................................................ 203
ExportType.................................................................................................................................................................... 203
Extension ....................................................................................................................................................................... 203
FileNamingType .......................................................................................................................................................... 204
FontPreviewType........................................................................................................................................................ 204
ForcedColors ................................................................................................................................................................ 204
FormatOptions ............................................................................................................................................................ 204
GalleryConstrainType................................................................................................................................................ 204
GalleryFontType.......................................................................................................................................................... 205
GallerySecurityTextColorType ............................................................................................................................... 205
GallerySecurityTextPositionType.......................................................................................................................... 205
GallerySecurityTextRotateType ............................................................................................................................. 205
GallerySecurityType................................................................................................................................................... 205
GalleryThumbSizeType............................................................................................................................................. 205
Geometry....................................................................................................................................................................... 205
GridLineStyle ................................................................................................................................................................ 205
GridSize .......................................................................................................................................................................... 205
GuideLineStyle............................................................................................................................................................. 206
IllustratorPathType..................................................................................................................................................... 206
Intent............................................................................................................................................................................... 206
Justification................................................................................................................................................................... 206
Language....................................................................................................................................................................... 206
LayerCompression...................................................................................................................................................... 206
LayerKind....................................................................................................................................................................... 207
LensType........................................................................................................................................................................ 207
MagnificationType ..................................................................................................................................................... 207
MatteType ..................................................................................................................................................................... 207
MeasurementRange .................................................................................................................................................. 207
MeasurementSource ................................................................................................................................................. 207
NewDocumentMode................................................................................................................................................. 207
NoiseDistribution........................................................................................................................................................ 208
OffsetUndefinedAreas .............................................................................................................................................. 208
OpenDocumentMode............................................................................................................................................... 208
OpenDocumentType...............................................................................................................
.................................. 208
Adobe Photoshop CS4
JavaScript Scripting Reference 30
OperatingSystem........................................................................................................................................................ 208
Orientation.................................................................................................................................................................... 208
OtherPaintingCursors ............................................................................................................................................... 209
PaintingCursors ........................................................................................................................................................... 209
PaletteType................................................................................................................................................................... 209
PathKind......................................................................................................................................................................... 209
PDFCompatibility........................................................................................................................................................ 209
PDFEncoding................................................................................................................................................................ 209
PDFResample ............................................................................................................................................................... 210
PDFStandard ................................................................................................................................................................ 210
PhotoCDColorSpace.................................................................................................................................................. 210
PhotoCDSize................................................................................................................................................................. 210
PICTBitsPerPixels......................................................................................................................................................... 210
PICTCompression........................................................................................................................................................ 210
PicturePackageTextType.......................................................................................................................................... 210
PointKind ....................................................................................................................................................................... 211
PointType ...................................................................................................................................................................... 211
PolarConversionType................................................................................................................................................ 211
Preview........................................................................................................................................................................... 211
PrintColorHandling .................................................................................................................................................... 211
PrintEncoding .............................................................................................................................................................. 211
PurgeTarget.................................................................................................................................................................. 211
QueryStateType........................................................................................................................................................... 211
RadialBlurMethod....................................................................................................................................................... 211
RadialBlurQuality ........................................................................................................................................................ 211
RasterizeType ............................................................................................................................................................... 211
ReferenceFormType .................................................................................................................................................. 212
ResampleMethod ....................................................................................................................................................... 212
RippleSize ...................................................................................................................................................................... 212
SaveBehavior................................................................................................................................................................ 212
SaveDocumentType .................................................................................................................................................. 212
SaveEncoding .............................................................................................................................................................. 212
SaveLogItemsType..................................................................................................................................................... 212
SaveOptionsType........................................................................................................................................................ 212
SelectionType............................................................................................................................................................... 213
ShapeOperation.......................................................................................................................................................... 213
SmartBlurMode ........................................................................................................................................................... 213
SmartBlurQuality......................................................................................................................................................... 213
SourceSpaceType ....................................................................................................................................................... 213
SpherizeMode.............................................................................................................................................................. 213
StrikeThruType ............................................................................................................................................................ 213
StrokeLocation............................................................................................................................................................. 213
TargaBitsPerPixels ...................................................................................................................................................... 213
TextCase......................................................................................................................................................................... 214
TextComposer.............................................................................................................................................................. 214
TextType ........................................................................................................................................................................ 214
TextureType.................................................................................................................................................................. 214
TIFFEncoding................................................................................................................................................................ 214
ToolType ........................................................................................................................................................................ 214
TransitionType ............................................................................................................................................................. 214
TrimType .......................................................................................................................
................................................. 215
Adobe Photoshop CS4
JavaScript Scripting Reference 31
TypeUnits....................................................................................................................................................................... 215
UndefinedAreas .......................................................................................................................................................... 215
UnderlineType ............................................................................................................................................................. 215
Units................................................................................................................................................................................. 215
Urgency.......................................................................................................................................................................... 215
WarpStyle ...................................................................................................................................................................... 215
WaveType...................................................................................................................................................................... 216
WhiteBalanceType...................................................................................................................................................... 216
ZigZagType................................................................................................................................................................... 216
Appendix A: Event ID Codes ...................................................................................................217
Index .........................................................................................................................................225
Adobe Photoshop CS4
JavaScript Scripting Reference 32
1
Introduction
This reference describes the objects and methods in the Adobe® Photoshop® CS4® JavaScriptTM type
library. A companion document, Photoshop CS4 Scripting Guide , describes basic scripting concepts and the
Photoshop object model. This document provides reference details of the Photoshop object model, and
additional information on JavaScript-specific features.
Adobe Photoshop CS4 uses ExtendScript, Adobe’s extended implementation of JavaScript. See JavaScript
support in Adobe Photoshop CS4 for additional information.
This book contains the following sections:
● This introduction, which describes scripting support in Adobe Photoshop CS4, and lists changes to the
JavaScript interface since the previous release.
● JavaScript Object Reference, which provides a complete reference for all Photoshop DOM objects and
commands.
● Scripting Constants, which lists all enumerations used in the Photoshop type library.
JavaScript support in Adobe Photoshop CS4
For a JavaScript file to be recognized by Photoshop as a valid script file, it must use either a .js or a .jsx
extension.
On the Mac OS, there is no difference in the way scripts with the two extensions function. On Windows, if
the script files is opened from inside Photoshop, there is no difference between using the
.js and .jsx
extension. However, if the script is launched by double-clicking on it, a script with the .js extension is
interpreted with the Microsoft JScript engine, and it cannot launch Adobe Photoshop CS4. For Windows,
using the
.jsx extension is preferrable, since it interprets the script with the ExtendScript engine.
All of the Adobe Creative Suite 4 applications, including Adobe Photoshop CS4, use ExtendScript, Adobe’s
extended implementation of JavaScript. ExtendScript files are distinguished by the
.jsx extension.
ExtendScript offers all standard JavaScript features, plus additional features and utilities, such as:
● A debugging environment (the ExtendScript Toolkit)
● A localization utility
● Tools that allow you to combine scripts and direct them to particular applications
● Platform-independent file and folder representation
Many of the JavaScript objects and methods use objects defined in ExtendScript, such as the
Folder object, and the UnitValue object. For that reason, using the .jsx extension for your script
the
File object,
files is preferable.
For details of these and additional features, see the JavaScript Tools Guide CS4. This document is installed
with Creative Suite 4 applications at these locations:
● In Windows:
C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit CS4\SDK
33
Adobe Photoshop CS4
JavaScript Scripting Reference Introduction 34
● In Mac OS:
Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CS4/SDK
The latest versions of this document and of the ExtendScript Tookit, can also be downloaded from Adobe
Developer Center, http://www.adobe.com/devnet/
.
Executing scripts
The Adobe Photoshop CS4 interface includes a Scripts menu (File > Scripts ) which provides quick and
easy access to your JavaScripts. Scripts can be listed directly as menu items that run when you select them,
or you can navigate to and run any JavaScript in your file system.
If Adobe Photoshop CS4 encounters an error during script execution, it displays the error message.
Installing scripts
To install a JavaScript in the Scripts menu, place it in the Scripts folder (Photoshop CS4/Presets/Scripts ).
The names of the scripts in the Scripts folder, without the file name extension, will be displayed in the
Scripts menu. Any number of scripts may be installed in the Scripts menu.
Scripts added to the Scripts folder while Adobe Photoshop CS4 is running will not appear in the Scripts
menu until the next time you launch the application.
All scripts found in the Scripts folder and sub-folders are displayed at the top level of the File > Scripts
menu. The addition of sub-folders does not add a hierarchical organization to the Scripts menu.
Executing other scripts
The Browse item at the end of the Scripts menu (File > Scripts > Browse ) allows you to execute scripts
which are not installed in the Scripts folder. You can also use Browse to select scripts installed in the Scripts
folder after the application was last launched.
Selecting Browse displays a file browser dialog which allows you to select a script file for execution. Only
.js or .jsx files are displayed in the browse dialog. When you select a script file, it is executed the same
way as an installed script.
Startup scripts
On startup, Adobe Photoshop CS4 executes all .jsx files that it finds in the startup folders.
● On Windows, the startup folder for user-defined scripts is:
C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop
● On Mac OS, the startup folder for user-defined scripts is:
~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop
If a script is meant to be executed only by Adobe Photoshop CS4, it must include code such as the
following:
if( BridgeTalk.appName == "photoshop" ) {
//continue executing script
}
For additional details, see the JavaScript Tools Guide CS4.
Adobe Photoshop CS4
JavaScript Scripting Reference Introduction 35
Object model usage and naming
The JavaScript API follows JavaScript naming conventions in that all classes (object types) begin with
uppercase letters and have mixed case. Typically, in JavaScript, you instantiate classes using the
operator:
new ClassName();
However, in the Photoshop Object Model, it is often not necessary to do this. Major object types are
collected into collection classes; for example, a list of
Document objects is contained in a Documents
collection object. You then access the collection object through a corresponding collection property in its
container in the object hierarchy.
new
For example, the collection of all open documents is contained in the top-level
can access this through the global variable
app.documents[0] // get the first loaded documented
documents[0] // this is the same
app, or simply reference its properties directly at the top level:
Application object. You
A collection property has the same name as the collection object, but begins with lowercase. For example,
a
Document contains a collection of LayerSets, and a LayerSet contains a collection of ArtLayers. To
access one
var myLayer = activeDocument.layerSets[0].artLayers[0];
ArtLayer object in a set:
The collections, as in this example, can be treated as arrays, which is useful for iteration. They also provide
methods to create their contained objects, and to access them by name:
var newLayer = activeDocument.artLayers.add(); // Create a new ArtLayer object
newLayer.name = "My Layer"; // name it for later reference
...
var layerRef = activeDocument.artLayers.getByName("My Layer");
Some objects, such as the Font objects contained in the app.fonts collection, are created by the
application, and never by your scripts.
Your scripts do use the JavaScript
new operator to create helper objects, such as those that encapsulate a
set of options for opening or saving a document in a particular format:
var opts = new PDFOpenOptions();
opts.page = 10;
app.open(myPDFFile, opts);
Changes since earlier versions - CS4 changes
The following changes have been made to the JavaScript object model and language support in Adobe
Photoshop CS4:
● New methods and properties:
● PrintSettings of type DocumentPrintSettings has been added to the Document object.
● togglePalettes method has been added to the Application object.
● runMenuItem method has been added to the Application object.
● printOneCopy method has been added to the Document object.
● build property has been added to the Application object.
● systemInformation property has been added to the Application object.
Adobe Photoshop CS4
JavaScript Scripting Reference Introduction 36
● layerMaskDensity property has been added to the ArtLayer object.
● layerMaskFeather property has been added to the ArtLayer object.
● vectorMaskDensity property has been added to the ArtLayer object.
● vectorMaskFeather property has been added to the ArtLayer object.
● filterMaskDensity property has been added to the ArtLayer object.
● filterMaskFeather property has been added to the ArtLayer object.
● xmpMetadata property has been added to the Layer object.
● New enumerations:
● DocPositionStyle has been added for the DocumentPrintSettings object.
● PrintColorHandling has been added for the DocumentPrintSettings object.
● PDFX42008 has been added for the PDFStandard object.
● PDF17 has been added for the PDFCompatibility object.
● Modified enumerations:
● LIGHTERCOLOR and DARKERCOLOR has been added to the BlendMode enumeration.
● BLACKANDWHITE and VIBRANCE has been added to the LayerKind enumeration.
Bug fixes
● size for the font is now of type UnitValue.
2
JavaScript Object Reference
The Photoshop objects (the JavaScript type library for Adobe® Photoshop® CS4) are presented
alphabetically and in tabular format in this chapter. Sample code for several object model classes is given
to help illustrate the syntax as well as usage of the object class.
Object descriptions
Object properties and methods are described in separate tables for each object. The following sections
describe the conventions used in these descriptions.
Properties notation
The Properties table for an object lists the following:
● The properties defined in each object.
● The value type for each property.
When the value type is a constant or another object, the value is a hypertext link to the listing for that
constant or object.
● The property’s input status: read-only or read-write.
● A description that explains what the property does.
Property Value type What it is
displayDialogs
For constants, like DialogModes in the sample, click the link to go to the table that shows allowed values.
Constants are represented by objects, and allowed values are properties of those objects. Specify a
constant value in the form ConstantName.VALUE. For example:
app.displayDialogs = DialogModes.ERROR;
Methods notation
The Methods table for an object lists the following:
● The method name.
● The parameters list.
● The parameter value types, on lines corresponding to each parameter.
● Return value type
● A description of what the method does, and further descriptions of parameters, if needed.
DialogModes
Read-write. The dialog mode for the application, which controls
what types of dialogs should be displayed when running
scripts.
37
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 38
Method Parameter type Returns What it does
crop
(bounds
[, angle]
[, width]
[, height])
array of 4
UnitValue
number
UnitValue
UnitValue
Crops the document. The
bounds parameter is an array of
four coordinates for the region
remaining after cropping, [left,
top, right, bottom].
When a parameter type or return value is a constant or another object, the value is a hypertext link to the
listing for that constant or object.
Parameters can be required or optional. Optional parameters are indicated in the table by square brackets
([]). In the example, the first parameters, bounds , is required. The remaining parameters are all optional.
You must pass a value for each required parameter. You can leave out optional parameters if there are no
remaining values to pass; however, if you wish to use the default value for any optional parameter that is
not the last one specified, pass
undefined as a placeholder. You must enter the values in the order they are
listed, so that the JavaScript compiler knows which value you are entering.
For example, the following passes only the required parameter (using a previously-defined variable for the
bounding region):
app.activeDocument.crop( myRegion );
The following skips the angle parameter, specifies the width value, and omits the final height value:
var myWidth = new UnitValue( "500 pixels" );
app.executeAction( myRegion,undefined,myWidth );
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 39
ActionDescriptor
This object provides a dictionary-style mechanism for storing data as key-value pairs. It can be used for
low-level access into Photoshop. See an example of this usage in ‘
Many configuration files use serialized action descriptors to represent their data. It is used, for example, to
encapsulate playback options in Application
Application
Properties
Property Value type What it is
.playbackParameters , and is returned by
.getCustomOptions ().
Selection sample script’ on page 169.
count
typename
Methods
Method Parameter type Returns What it does
clear
erase
fromStream
getBoolean
getClass
getData
()
(key)
(value)
(key)
(key)
(key)
number
string
number
string
number
number
number
Read-only. The number of keys contained in the descriptor.
Read-only. The class name of the referenced
actionDescriptor object.
Clears the descriptor.
Erases a key from the descriptor.
Creates a descriptor from a stream
of bytes; for reading from disk.
boolean
Gets the value of a key of type
boolean.
number
Gets the value of a key of type
class.
string
Gets raw byte data as a string
value.
getDouble
(key)
getEnumerationType
(key)
getEnumerationValue
(key)
getInteger
(key)
getKey
(index)
number
number
number
number
number
number
number
number
number
number
Gets the value of a key of type
double.
Gets the enumeration type of a
key.
Gets the enumeration value of a
key.
Gets the value of a key of type
integer.
Gets the ID of the N th key,
provided by index.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 40
Method Parameter type Returns What it does (Continued)
getList
(key)
getObjectType
(key)
getObjectValue
(key)
getPath
(key)
getReference
(key)
getString
(key)
getType
(key)
getUnitDoubleType
(key)
getUnitDoubleValue
(key)
number
number
number
number
number
number
number
number
number
ActionList
number
ActionDescriptor
File
ActionReference
string
DescValueType
number
number
Gets the value of a key of type list.
Gets the class ID of an object in a
key of type object.
Gets the value of a key of type
object.
Gets the value of a key of type
File.
Gets the value of a key of type
ActionReference.
Gets the value of a key of type
string.
Gets the type of a key.
Gets the unit type of a key of type
UnitDouble.
Gets the value of a key of type
UnitDouble.
hasKey
(key)
isEqual
(otherDesc)
putBoolean
(key,
value)
putClass
(key,
value)
putData
(key,
value)
putDouble
(key,
value)
putEnumerated
(key,
enumType,
value)
number
ActionDescriptor
number
boolean
number
number
number
string
number
number
number
number number
boolean
boolean
Checks whether the descriptor
contains the provided key.
Determines whether the
descriptor is the same as another
descriptor.
Sets the value for a key whose type
is boolean.
Sets the value for a key whose type
is class.
Puts raw byte data as a string
value.
Sets the value for a key whose type
is double.
Sets the enumeration type and
value for a key.
putInteger
(key,
value)
number
number
Sets the value for a key whose type
is integer.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 41
Method Parameter type Returns What it does (Continued)
putList
(key,
value)
putObject
(key,
classID,
value)
putPath
(key,
value)
putReference
(key,
value)
putString
(key,
value)
putUnitDouble
(key,
unitID,
value)
toStream
()
number
ActionList
number
number
ActionDescriptor
number
File
number
ActionReference
number
string
number
number
number
string
Sets the value for a key whose type
is an
ActionList object.
Sets the value for a key whose type
is an object, represented by an
Action Descriptor.
Sets the value for a key whose type
is path.
Sets the value for a key whose type
is an object reference.
Sets the value for a key whose type
is string.
Sets the value for a key whose type
is a unit value formatted as a
double.
Gets the entire descriptor as a
stream of bytes, for writing to disk.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 42
ActionList
This object provides an array-style mechanism for storing data. It can be used for low-level access into
Photoshop.
This object is ideal when storing data of the same type. All items in the list must be of the same type.
You can use the "put" methods, such as putBoolean
list using clear
Note: The
Properties
Property Value type What it is
count
typename
Methods
With the exception of the clear() method, you use the methods of this object to either get the value of a
specific type of data in the list or set (put) the value type.
Method Parameter type Returns What it does
clear
()
(), to append new elements, and can clear the entire
(), but cannot otherwise modify the list.
ActionList object is part of the Action Manager functionality. For details on using the Action
Manager, see the Photoshop CS4 Scripting Guide .
number
Read-only. The number of commands that comprise the
action.
string
Read-only. The class name of the referenced
ActionList object.
Clears the list.
getBoolean
(index)
getClass
(index)
getData
(index)
getDouble
(index)
getEnumerationType
(index)
getEnumerationValue
(index)
getInteger
(index)
number
number
number
number
number
number
number
boolean
number
string
number
number
number
number
Gets the value of a list element of
type boolean.
Gets the value of a list element of
type class.
Gets raw byte data as a string
value.
Gets the value of a list element of
type double.
Gets the enumeration type of a list
element.
Gets the enumeration value of a
list element.
Gets the value of a list element of
type integer.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 43
Method Parameter type Returns What it does (Continued)
getList
(index)
getObjectType
(index)
getObjectValue
(index)
getPath
(index)
getReference
(index)
getString
(index)
getType
(index)
getUnitDoubleType
(index)
getUnitDoubleValue
(index)
number
number
number
number
number
number
number
number
number
ActionList
number
ActionDescriptor
File
ActionReference
string
DescValueType
number
number
Gets the value of a list element of
type list.
Gets the class ID of a list element
of type object.
Gets the value of a list element of
type object.
Gets the value of a list element of
type
File.
Gets the value of a list element of
type
ActionReference.
Gets the value of a list element of
type string.
Gets the type of a list element.
Gets the unit value type of a list
element of type Double.
Gets the unit value of a list
element of type double.
putBoolean
(value)
putClass
(value)
putData
(value)
putDouble
(value)
putEnumerated
(enumType,
value)
putInteger
(value)
putList
(value)
putObject
(classID,
value)
putPath
(value)
boolean
number
string
number
number
number
number
ActionList
number
ActionDescriptor
File
Appends a new value, true or
false.
Appends a new value, a class or
data type.
Appends a new value, a string
containing raw byte data.
Appends a new value, a double.
Appends a new value, an
enumerated (constant) value.
Appends a new value, an integer.
Appends a new value, a nested
action list.
Appends a new value, an object.
Appends a new value, a path.
putReference
(value)
ActionReference
Appends a new value, a reference
to an object created in the script.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 44
Method Parameter type Returns What it does (Continued)
putString
(value)
putUnitDouble
(classID,
value)
string
number
number
Appends a new value, a string.
Appends a new value, a unit/value
pair.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 45
ActionReference
This object provides information about what the action is refering to. For example, when referring to the
name of something you might use keyName. The reference would also need to know what name you are
referring to. In this case you could use classDocument for the name of the document or classLayer for the
name of the layer. It can be used for low-level access into Photoshop.Contains data associated with an
ActionDescriptor
Properties
Property Value type What it does
.
typename
Methods
Method Parameter type Returns What it does
getContainer
getDesiredClass
getEnumeratedType
getEnumeratedValue
()
()
()
()
string
Read-only. The class name of the referenced Action
object.
ActionReference
Gets a reference contained in this
reference.
Container references provide
additional pieces to the reference.
This looks like another reference,
but it is actually part of the same
reference.
number
Gets a number representing the
class of the object.
number
number
Gets the enumeration type.
Gets the enumeration value.
getForm
()
getIdentifier
()
getIndex
()
getName
()
getOffset
()
getProperty
()
ReferenceFormType
number
number
string
number
number
Gets the form of this action
reference.
Gets the identifier value for a
reference whose form is identifier.
Gets the index value for a
reference in a list or array.
Gets the name of a reference.
Gets the offset of the object’s
index value.
Gets the property ID value.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 46
Method Parameter type Returns What it does (Continued)
putClass
(desiredClass)
putEnumerated
(desiredClass,
enumType,
value)
putIdentifier
(desiredClass,
value)
putIndex
(desiredClass,
value)
putName
(desiredClass,
value)
putOffset
(desiredClass,
value)
putProperty
(desiredClass,
value)
number
number
number
number
number
number
number
number
number
string
number
number
number
number
Puts a new class form and class
type into the reference.
Puts an enumeration type and ID
into a reference along with the
desired class for the reference.
Puts a new identifier and value into
the reference.
Puts a new index and value into
the reference.
Puts a new name and value into
the reference.
Puts a new offset and value into
the reference.
Puts a new property and value into
the reference.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 47
Application
The Adobe Adobe Photoshop CS4 application object, which is the root of the object model and provides
access to all other objects. This object provides application-wide information, such as application defaults
and available fonts. It provides many important methods , such as those for opening files and loading
documents.
To access the properties and methods, you can use the pre-defined global variable
var docRef = app.documents.add(800, 600, 72, "docRef", NewDocumentMode.RGB);
The properties and methods of the Application object are also available at the top level; you can omit
references to the
var docRef = documents.add(800, 600, 72, "docRef", NewDocumentMode.RGB);
This usage can be somewhat ambiguous; for clarity, it is recommended that you use an explicit reference
to
app.
Properties
Property Value type What it is
activeDocument
backgroundColor
Application object altogether. For example:
Document
Read-write. The frontmost document.
Setting this property is equivalent to clicking an
open document in the Adobe Photoshop CS4
application to bring it to the front of the screen.
Tip: If there is no open document, accessing this
property throws an exception.
SolidColor
Read-write. The default background color and color
style for documents.
app. For example:
build
colorSettings
displayDialogs
documents
fonts
foregroundColor
freeMemory
string
string
DialogModes
Documents
TextFonts
SolidColor
number
Read-only. Information about the application.
Read-write. The name of the current color settings,
as selected with Edit > Color Settings.
Read-write. The dialog mode for the application,
which controls what types of dialogs should be
displayed when running scripts.
Read-only. The collection of open documents.
This is the primary point of access for documents
that are currently open in the application. The array
allows you to access any open document, or to
iterate through all open documents.
Read-only. The fonts installed on this system.
Read-write. The default foreground color (used to
paint, fill, and stroke selections).
Read-only. The amount of unused memory
available to Adobe Photoshop CS4.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 48
Property Value type What it is (Continued)
locale
macintoshFileTypes
measurementLog
name
notifiers
notifiersEnabled
path
playbackDisplayDialogs
string
array of string
MeasurementLog
string
Notifiers
boolean
File
DialogModes
Read-only. The language location of the
application.
An Adobe locale code consists of a 2-letter ISO-639
language code and an optional 2-letter ISO 3166
country code separated by an underscore. Case is
significant. For example,
fr_FR.
en_US, en_UK, ja_JP, de_DE,
Read-only. A list of file image types Adobe
Photoshop CS4 can open.
The log of measurements taken.
Read-only. The application's name.
Read-only. The collection of notifiers currently
configured (in the Scripts Events Manager menu in
the Adobe Photoshop CS4 application).
Read-write. True if all notifiers are enabled.
Read-only. The full path to the location of the
Adobe Photoshop CS4 application.
Read-write. The dialog mode for playback mode,
which controls what types of dialog to display
when playing back a recorded action with the
Actions palette.
playbackParameters
preferences
preferencesFolder
recentFiles
scriptingBuildDate
scriptingVersion
systemInformation
typename
ActionDescriptor
Preferences
File
array of File
string
string
string
string
Read-write. Stores and retrieves parameters used as
part of a recorded action. Can be used, for example,
to control playback speed.
Read-only. The application preference settings
(equivalent to selecting Edit > Preferences in the
Adobe Photoshop CS4 application in Windows or
Photoshop > Preferences in Mac OS).
Read-only. The full path to the Preferences folder.
Read-only. Files in the Recent Files list.
Read-only. The build date of the Scripting interface.
Read-only. The version of the Scripting interface.
Read-only. Runtime details of the application and
system.
Read-only. The class name of the referenced app
object.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 49
Property Value type What it is (Continued)
version
string
Read-only. The version of Adobe Photoshop
application you are running.
windowsFileTypes
array of string
Read-only. A list of file image extensions Adobe
Photoshop CS4 can open.
Methods
Method Parameter type Returns What it does
batch
(inputFiles,
action,
from
[, options])
beep
()
bringToFront
()
charIDToTypeID
(charID)
array of File
string
string
BatchOptions
string
string
number
Runs the batch automation routine
(similar to the File > Automate >
Batch command).
inputFiles parameter specifies
The
the sources for the files to be
manipulated by the batch command.
Causes a "beep" sound.
Makes Adobe Photoshop CS4 the
active (front-most) application.
Converts from a four character code
(character ID) to a runtime ID.
doAction
(action,
from)
eraseCustomOptions
(key)
executeAction
(eventID
[, descriptor]
[, displayDialogs])
executeActionGet
(reference)
featureEnabled
(name)
string
string
string
number
ActionDescriptor
DialogModes
ActionReference
string
ActionDescriptor
ActionDescriptor
boolean
Plays an action from the Actions
palette. The
name of the action, the
action parameter is the
from
parameter is the name of the action
set.
Erases the user object with specified
ID value from the Photoshop registry.
Plays an Action Manager event.
Obtains information about a
predefined or recorded action.
Determines whether the feature
specified by
name is enabled.
The following features are supported
as values for
"photoshop/extended"
"photoshop/standard"
"photoshop/trial"
name:
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 50
Method Parameter type Returns What it does (Continued)
getCustomOptions
(key)
load
(document)
makeContactSheet
(inputFiles
[, options])
makePDFPresentation
(inputFiles,
outputFiles
[, options])
makePhotoGallery
(inputFolder,
outputFolder
[, options])
makePhotomerge
(inputFiles)
string
File
array of File
ContactSheetOptions
array of File
File
PresentationOptions
File
File
GalleryOptions
array of File
ActionDescriptor
string
string
string
string
Retreives user objects in the
Photoshop registry for the ID with
value
key.
Loads a support file (as opposed to a
Photoshop image document) from
the specified location.
Creates a contact sheet from the
specified files.
Creates an Adobe PDF presentation
file from the specified input files.
The return string contains the path to
the PDF file.
Creates a web photo gallery from the
files in the specified input folder.
DEPRECATED for Adobe Photoshop CS4.
Use provided script:
runphotomergeFromScript = true;
$.evalFile( app.path +
"Presets/Scripts/Photomerge.jsx")
photomerge.createPanorama(
fileList, displayDialog );
Merges multiple files into one, with
user interaction required.
makePicturePackage
(inputFiles
[, options])
array of File
PicturePackageOptions
string
Creates a picture package from the
specified input files.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 51
Method Parameter type Returns What it does (Continued)
open
(document
[, as]
[, asSmartObject])
openDialog
()
File
object or OpenDocumentType
boolean
Document
array of File
Opens the specified document.
Use the optional
as parameter to
specify the file format using the
constants in
OpenDocumentType; or,
you can specify a file format together
with its open options using these
objects:
CameraRAWOpenOptions
DICOMOpenOptions
EPSOpenOptions
PDFOpenOptions
PhotoCDOpenOptions
RawFormatOpenOptions
Use the optional parameter
asSmartObject (default: false) to
create a smart object around the
opened document.
See the Application sample scripts
an example of using the
open method.
in the
File object
for
Invokes the Photoshop Open dialog
box for the user to select files.
Returns an array of
File objects for
the files selected in the dialog.
purge
(target)
putCustomOptions
(key,
customObject
[, persistent])
refresh
()
runMenuItem
(menuID)
stringIDToTypeID
(stringID)
PurgeTarget
string
ActionDescriptor
boolean
number
string
number
Purges one or more caches.
Saves a customized settings object in
the Photoshop registry.
key is the unique identifier for your
custom settings.
customObject is the object to save in
the registry.
persistent indicates whether the
object should persist once the script
has finished.
Pauses the script while the
application refreshes. Use to slow
down execution and show the results
to the user as the script runs. Use
carefully; your script runs much more
slowly when using this method.
Run a menu item given the menu ID.
Converts from a string ID to a runtime
ID.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 52
Method Parameter type Returns What it does (Continued)
togglePalettes
()
typeIDToCharID
(typeID)
typeIDToStringID
(typeID)
Application sample scripts
Application.jsx
This script invokes an alert box to display Properties important to an application such as version number,
the path to the application, the amount of memory available, and the number of documents open.
When a user presses the OK button on the alert box, a second dialog opens, which asks users whether they
would like the foreground and background colors set for the document presently open. If no document is
open, the script opens a new document for the user.
The script (with no document open) produces a progression of three dialogs.
//Create a Welcome message
// Use the name and version properties of the application object to
// Append the application’s name and version to the Welcome message
// use "\r" to insert a carriage return
// use the combination operator += to append info to the message
var message = "Welcome to " + app.name
message += " version " + app.version + "\r\r"
number
number
string
string
Toggle palette visibility.
Converts from a runtime ID to a
character ID.
Converts from a runtime ID to a string
ID.
// find out where Adobe Photoshop CS4 is installed
// and add the path to the message
// add the optional parameter fsName to the path property
// to display the file system name in the most common format
message += "I’m installed in " + app.path.fsName + "\r\r"
// see how much memory Adobe Photoshop CS4 has to play with
message += "You have this much memory available for Adobe Photoshop CS4: " +
app.freeMemory + "\r\r"
// use the length property of the documents object to
// see how many documents are open
var documentsOpen = app.documents.length
message += "You currently have " + documentsOpen + " document(s) open.\r\r"
// display the message to the user
alert(message)
// answer will be true for a "Yes" answer and false for a "No" answer
var answer = confirm("Set the foreground and background to my favorite colors?")
// set the colors
if (answer) {
// I don’t have a favorite color. Why did I ask you may wonder?
app.foregroundColor.rgb.red = Math.random() * 255
app.foregroundColor.rgb.green = Math.random() * 255
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 53
app.foregroundColor.rgb.blue = Math.random() * 255
app.backgroundColor.rgb.red = Math.random() * 255
app.backgroundColor.rgb.green = Math.random() * 255
app.backgroundColor.rgb.blue = Math.random() * 255
}
// Open a document
if (app.documents.length == 0) {
// use the application’s path and the offset to the samples folder
var sampleDocToOpen = File(app.path + "/Samples/Fish.psd")
// compose a message with the name of the file
message = "Would you like me to open a sample for you? ("
message += sampleDocToOpen.fsName
message += ")"
// ask the user another question
answer = confirm(message)
// open the document accordingly
if (answer) {
open(sampleDocToOpen)
}
}
PDFPresentation.jsx
This script presents a progression of images as an Adobe PDF slide show.
// use all the files in the Samples folder
var inputFolder = new Folder(app.path + "/Samples/")
// see if we have something interesting
if (inputFolder != null) {
// get all the files found in this folder that are Adobe Photoshop CS4 (.psd
format)
var inputFiles = inputFolder.getFiles("*.psd")
// output to the desktop
var outputFile = File("~/Desktop/JavaScriptPresentation.pdf")
// there are defaults but I like to set the options myself
var options = new PresentationOptions
options.presentation = true
options.view = true
options.autoAdvance = true
options.interval = 5
options.loop = true
options.transition = TransitionType.RANDOM
// create the presentation
makePDFPresentation(inputFiles, outputFile, options)
alert("Presentation file saved to: " + outputFile.fsName)
}
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 54
ArtLayer
An object within a document that contains the visual elements of the image (equivalent to a layer in the
Adobe Photoshop CS4 application).
Access an art layer in a document through the Document
name; for example:
var layerRef = app.activeDocument.artLayers.getByName("my layer");
layerRef.allLocked = true;
Access the art layers in a layer set through the LayerSet. artLayers collection in the parent set.
Properties
Property Value type What it is
allLocked
blendMode
bounds
fillOpacity
filterMaskDensity
boolean
BlendMode
array of
UnitValue
number [0.0..100]
double
.artLayers collection. You can access a layer by
Read-write. True to completely lock the contents and
settings of this layer.
Read-write. The blending mode.
Read-only. An array of coordinates that describes the
bounding rectangle of the layer.
Read-write. The interior opacity of the layer, a
percentage value.
Read-write. The density of the filter mask (between
0.0 and 250.0)
filterMaskFeather
grouped
isBackgroundLayer
kind
layerMaskDensity
double
boolean
boolean
LayerKind
double
Read-write. The feather of the filter mask (between 0.0
and 250.0)
Read-write. True if this layer is grouped with the layer
beneath it.
Read-write. True if this is the background layer of the
document. A document can have only one
background layer. If there is no background layer,
setting this to true causes this to become the
background layer.
Read-write. Sets the type (such as 'text layer') for an
empty layer.
Valid only when the layer is empty and when
isBackgroundLayer is false. See
isBackgroundLayer
You can use the
.
kind property to make a background
layer a normal layer; however, to make a layer a
background layer, you must set
to
true.
isBackgroundLayer
Read-write. The density of the layer mask (between
0.0 and 100.0)
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 55
Property Value type What it is (Continued)
layerMaskFeather
linkedLayers
name
opacity
parent
pixelsLocked
positionLocked
textItem
transparentPixelsLocked
typename
double
array of ArtLayer
or LayerSet
string
number [0.0..100.0].
Document
boolean
boolean
TextItem
boolean
string
Read-write. The feather of the layer mask (between
0.0 and 250.0)
Read-only. The layers linked to this layer. See
ArtLayer
.link .
Read-write. The name.
Read-write. The master opacity of the layer, a
percentage value.
Read-only. The object's container.
Read-write. True if the pixels in the layer’s image
cannot be edited using the paintbrush tool.
Read-write. True if the pixels in the layer’s image
cannot be moved within the layer.
Read-only. The text item that is associated with the
layer.
Valid only when kind
= LayerKind.TEXT.
Read-write. True if editing is confined to the opaque
portions of the layer.
Read-only. The class name of the referenced
artLayer object.
vectorMaskDensity
vectorMaskFeather
visible
xmpMetadata
double
double
boolean
xmpMetadata
Read-write. The density of the vector mask (between
0.0 and 250.0)
Read-write. The feather of the vector mask (between
0.0 and 250.0)
Read-write. True if the layer is visible.
Read-write. Metadata for the layer.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 56
Methods
Method Parameter type Returns What it does
adjustBrightnessContrast
(brightness,
contrast)
adjustColorBalance
([shadows]
[, midtones]
[, highlights]
[, preserveLuminosity]
adjustCurves
(curveShape)
adjustLevels
(inputRangeStart,
inputRangeEnd,
inputRangeGamma,
outputRangeStart,
outputRangeEnd)
number
number
array of number
array of number
array of number
boolean
array of array of number
number
number [(start + 2)..255]
number [0.10..9.99]
number [0..253]
number [(start + 2)..255]
[0..253]
Adjusts the brightness in the
range [-100..100] and contrast
[-100..100].
Adjusts the color balance of the
layer’s component channels. For
shadows, midtones, and
highlights, the array must
include three values in the
range [-100..100], which
represent cyan or red, magenta
or green, and yellow or blue,
when the document mode is
CMYK or RGB.
Document.mode.
See
Adjusts the tonal range of the
selected channel using up to
fourteen points.
Each value in the
curveShape
array is a point pair, an array of
an x and y integer value.
Adjusts the levels of the
selected channels
applyAddNoise
(amount,
distribution,
monochromatic)
applyAverage
()
applyBlur
()
applyBlurMore
()
applyClouds
()
applyCustomFilter
(characteristics,
scale,
offset)
number
NoiseDistribution
boolean
array of number
number
number
[0.1..400]
Applies the Add Noise filter
amount is a percentage value.
Applies the Average filter.
Applies the Blur filter.
Applies the Blur More filter.
Applies the Clouds filter.
Applies a custom filter.
characteristics array has
The
25 members.
See Adobe Photoshop CS4 Help
for specific instructions.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 57
Method Parameter type Returns What it does (Continued)
applyDeInterlace
(eliminateFields,
createFields)
applyDespeckle
()
applyDifferenceClouds
()
applyDiffuseGlow
(graininess,
glowAmount,
clearAmount)
applyDisplace
(horizontalScale,
verticalScale,
displacement,
undefinedareas,
displacementMapFiles)
applyDustAndScratches
(radius,
threshold)
applyGaussianBlur
(radius)
EliminateFields
CreateFields
number [0..10]
number [0..20]
number [0..20]
number [-999..999]
number [-999..999]
DisplacementMapType
UndefinedAreas
File
number [1..100]
number [0..255]
number [0.1..250.0]
Applies the De-Interlace filter.
Applies the Despeckle filter.
Applies the Difference Clouds
filter.
Applies the Diffuse Glow filter.
Applies the Displace filter using
the specified horizontal and
vertical scale, mapping type,
treatment of undistorted areas,
and path to the distortion
image map.
Applies the Dust & Scratches
filter.
Applies the Gaussian Blur filter
within the specified radius (in
pixels)
applyGlassEffect
(distortion,
smoothness,
scaling
[, invert]
[, texture]
[, textureFile])
applyHighPass
(radius)
number [0..20]
number [1..15]
number [50..200]
boolean
TextureType
File
number [0.1..250.0]
Applies the Glass filter.
scaling is a percentage value.
Applies the High Pass filter
within the specified radius.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 58
Method Parameter type Returns What it does (Continued)
applyLensBlur
([source]
[, focalDistance]
[, invertDepthMap]
[, shape]
[, radius]
[, bladeCurvature]
[, rotation]
[, brightness]
[, threshold]
[, amount]
[, distribution]
[, monochromatic]
)
DepthMapSource
number
boolean
Geometry
number
number
number
number
number
number
NoiseDistribution
boolean
Applies the Lens Blur filter.
source: The source for the
depth map (default:
DepthMapSource.NONE)
focalDistance : The blur focal
distance for the depth map
(default:
invertDepthMask : True if the
0).
depth map is inverted (default:
false).
shape: The shape of the iris
(default:
radius
(default:
bladeCurvature: The blade
curvature of the iris (default:
rotation: The rotation of the
iris (default:
brightness: The brightness for
Geometry.HEXAGON)
: The radius of the iris
15).
0).
0)
the specular highlights (default:
0).
applyLensFlare
(brightness,
flareCenter,
lensType)
applyMaximum
(radius)
applyMedianNoise
(radius)
number
array(UnitValue
LensType
number [1..100]
number [1..100]
threshold: The threshold for
the specular highlights (default:
0).
amount: The amount of noise
(default:
distribution: The distribution
0)
value for the noise (default:
NoiseDistribution.UNIFORM).
monochromatic: True if the
noise is monochromatic
(default:
false).
Applies the Lens Flare filter with
)
the specified brightness (0 - 300,
as a percentage), the x and y
coordinates (unit value) of the
flare center, and the lens type.
Applies the Maximum filter
within the specified radius (in
pixels).
Applies the Median Noise filter
within the specified radius (in
pixels).
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 59
Method Parameter type Returns What it does (Continued)
applyMinimum
(radius)
applyMotionBlur
(angle,
radius)
applyNTSC
()
applyOceanRipple
(size,
magnitude)
applyOffset
(horizontal,
vertical,
undefinedAreas)
applyPinch
(amount)
applyPolarCoordinates
(conversion)
number [1..100]
number [-360..360]
number [1..999]
number [1..15]
number [0..20]
UnitValue
UnitValue
OffsetUndefinedAreas
number [-100..100]
PolarConversionType
Applies the Minimum filter
within the specified radius (in
pixels) (1 - 100).
Applies the Motion Blur filter.
Applies the NTSC colors filter.
Applies the Ocean Ripple filter.
Moves the layer the specified
amount horizontally and
vertically (min/max amounts
depend on layer size), leaving
an undefined area at the layer’s
original location.
Applies the Pinch filter.
amount is a percentage value.
Applies the Polar Coordinates
filter.
applyRadialBlur
(amount,
blurMethod,
blurQuality)
applyRipple
(amount,
size)
applySharpen
()
applySharpenEdges
()
applySharpenMore
()
applyShear
(curve,
undefinedAreas)
number [1..100]
RadialBlurMethod
RadialBlurQuality
number [-999..999]
RippleSize
array of array of number
UndefinedAreas
Applies the Radial Blur filter in
the specified amount, using
either a spin or zoom effect and
the specified quality.
Applies the Ripple filter in the
specified amount, throughout
the image and in the specified
size.
Applies the Sharpen filter.
Applies the Sharpen Edges filter.
Applies the Sharpen More filter.
Applies the Shear filter. The
curve defines a curve with
[2..255] points.
Each value in the
curve array is a
point pair, an array of an x and y
integer value.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 60
Method Parameter type Returns What it does (Continued)
applySmartBlur
(radius,
threshold,
blurQuality,
mode)
applySpherize
(amount,
mode)
applyStyle
(styleName)
applyTextureFill
(textureFile)
applyTwirl
(angle)
applyUnSharpMask
(amount,
radius,
threshold)
applyWave
(generatorNumber,
minimumWavelength,
maximumWavelength,
minimumAmplitude,
maximumAmplitude,
horizontalScale,
verticalScale,
waveType,
undefinedAreas,
randomSeed)
number [0.1..100.0]
number [0.1..100.0]
SmartBlurQuality
SmartBlurMode
number [-100..100]
SpherizeMode
string
File
number [-999..999]
number [1..500]
number [0.1..250.0]
number [0..255]
number [1..999]
number [1..998]
number [2..min +1]
number[1..998]
number [2..min +1]
number [1..100]
number [1..100]
WaveType
UndefinedAreas
number
Applies the Smart Blur filter.
Applies the Spherize filter.
amount is a percentage value.
Applies the specified style to the
layer. You must use a style from
the Styles list in the Layer Styles
Palette.
Applies the Texture Fill filter.
Applies the Twirl filter.
Applies the Unsharp Mask filter.
amount is a percentage value.
(
Applies the Wave filter.
Scale factors are percentage
values.
applyZigZag
(amount,
ridges,
style)
autoContrast
()
autoLevels
()
clear
()
number [-100..100]
Applies the Zigzag filter.
number [0..20]
ZigZagType
Adjusts the contrast of the
selected channels automatically.
Adjusts the levels of the
selected channels using the
auto levels option.
Cuts the layer without moving it
to the clipboard.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 61
Method Parameter type Returns What it does (Continued)
copy
([merge])
cut
()
desaturate
()
duplicate
([relativeObject]
[, insertionLocation])
equalize
()
boolean
ArtLayer
ElementPlacement
or LayerSet
ArtLayer
or
LayerSet
Copies the layer to the
clipboard. When the optional
argument is set to
true, a
merged copy is performed (that
is, all visible layers are copied to
the clipboard).
Cuts the layer to the clipboard.
Converts a color image to a
grayscale image in the current
color mode by assigning equal
values of each component color
to each pixel.
Creates a duplicate of the object
on the screen.
Redistributes the brightness
values of pixels in an image to
more evenly represent the
entire range of brightness levels
within the image.
invert
()
link
(with)
merge
()
ArtLayer
or LayerSet
ArtLayer
Inverts the colors in the layer by
converting the brightness value
of each pixel in the channels to
the inverse value on the
256-step color-values scale.
Links the layer with the
specified layer.
Merges the layer down,
removing the layer from the
document; returns a reference
to the art layer that this layer is
merged into.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 62
Method Parameter type Returns What it does (Continued)
mixChannels
(outputChannels
[, monochrome])
move
(relativeObject,
insertionLocation)
array of array of number
boolean
ArtLayer
ElementPlacement
or LayerSet
Modifies a targeted (output)
color channel using a mix of the
existing color channels in the
image.
outputChannels
The
parameter is an array of channel
specifications. For each
component channel, specify a
list of adjustment values in the
range [-200..200] followed by a
'constant' value [-200..200].)
monochrome = true, the
When
maximum number of channel
value specifications is 1.
Valid only when
DocumentMode.RGB or CMYK.
docRef.mode =
RGB arrays must include four
values. CMYK arrays must
include five values.
Moves the layer relative to the
object specified in parameters.
For art layers, only the constant
ElementPlacement.
values
PLACEBEFORE
and PLACEAFTER
are valid.
photoFilter
([fillColor]
[, density]
[, preserveLuminosity])
posterize
(levels)
rasterize
(target)
remove
()
SolidColor
number [1..100]
boolean
number [2..225]
RasterizeType
For layer sets, only the constant
ElementPlacement.
values
PLACEBEFORE
and INSIDE are
valid.
Adjust the layer’s color balance
and temperature as if a color
filter had been applied.
density is a percentage value.
Specifies the number of tonal
levels for each channel and then
maps pixels to the closest
matching level.
Converts the targeted contents
in the layer into a flat, raster
image.
Deletes the object.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 63
Method Parameter type Returns What it does (Continued)
resize
([horizontal]
[, vertical]
[, anchor])
rotate
(angle
[, anchor])
selectiveColor
(selectionMethod
[, reds]
[, yellows]
[, greens]
[, cyans]
[, blues]
[, magentas]
[, whites]
[, neutrals]
[, blacks])
shadowHighlight
([shadowAmount]
[, shadowWidth]
[, shadowRadius]
[, highlightAmount]
[, highlightWidth]
[, highlightRadius]
[, colorCorrection]
[, midtoneContrast]
[, blackClip]
[, whiteClip])
number
number
AnchorPosition
number
AnchorPosition
AdjustmentReference
array of number
array of number
array of number
array of number
array of number
array of number
array of number
array of number
array of number
number [0..100]
number [0.100]
number [0..2500]
number [0..100]
number [0..100]
number [0..2500]
number [-100..100]
number [-100..100]
number [0.000..50.000]
number [0.000..50.000]
Resizes the layer to the specified
dimensions (as a percentage of
its current size) and places it in
the specified position.
Rotates rotates the layer around
the specified anchor point
(default:
MIDDLECENTER).
Modifies the amount of a
process color in a specified
primary color without affecting
the other primary colors.
Each color array must have four
values.
Adjusts the range of tones in the
image’s shadows and highlights.
Amounts and widths are
percentage values. Radius
values are in pixels.
threshold
(level)
number [1..255]
Converts grayscale or color
images to high-contrast, B/W
images by converting pixels
lighter than the specified
threshold to white and pixels
darker than the threshold to
black.
translate
([deltaX]
[, deltaY])
unlink
()
UnitValue
UnitValue
Moves the layer the specified
amount (in the given unit)
relative to its current position.
Unlinks the layer.
ArtLayer sample Script
The following script opens all the files in the samples folder, creating one multi-layered document. Each
layer is pasted into one of four quadrants and given 50% transparency. Finally the layers are sorted by
name.
ArtLayer.jsx
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 64
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// Set Adobe Photoshop CS4 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
//Close all the open documents
while (app.documents.length) {
app.activeDocument.close()
}
// Create a new document to merge all the samples into
var mergedDoc = app.documents.add(1000, 1000, 72, "Merged Samples",
NewDocumentMode.RGB, DocumentFill.TRANSPARENT, 1)
// Use the path to the application and append the samples folder
var samplesFolder = Folder(app.path + "/Samples/")
//Get all the files in the folder
var fileList = samplesFolder.getFiles()
// open each file
for (var i = 0; i < fileList.length; i++) {
// The fileList is folders and files so open only files
if (fileList[i] instanceof File) {
open(fileList[i])
// use the document name for the layer name in the merged document
var docName = app.activeDocument.name
// flatten the document so we get everything and then copy
app.activeDocument.flatten()
app.activeDocument.selection.selectAll()
app.activeDocument.selection.copy()
// don’t save anything we did
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)
// make a random selection on the document to paste into
// by dividing the document up in 4 quadrants and pasting
// into one of them by selecting that area
var topLeftH = Math.floor(Math.random() * 2)
var topLeftV = Math.floor(Math.random() * 2)
var docH = app.activeDocument.width.value / 2
var docV = app.activeDocument.height.value / 2
var selRegion = Array(Array(topLeftH * docH, topLeftV * docV),
Array(topLeftH * docH + docH, topLeftV * docV),
Array(topLeftH * docH + docH, topLeftV * docV + docV),
Array(topLeftH * docH, topLeftV * docV + docV),
Array(topLeftH * docH, topLeftV * docV))
app.activeDocument.selection.select(selRegion)
app.activeDocument.paste()
// change the layer name and opacity
app.activeDocument.activeLayer.name = docName
app.activeDocument.activeLayer.fillOpacity = 50
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 65
}
}
// sort the layers by name
for (var x = 0; x < app.activeDocument.layers.length; x++) {
for (var y = 0; y < app.activeDocument.layers.length - 1 - x; y++) {
// Compare in a non-case sensitive way
var doc1 = app.activeDocument.layers[y].name
var doc2 = app.activeDocument.layers[y + 1].name
if (doc1.toUpperCase() > doc2.toUpperCase()) {
app.activeDocument.layers[y].move(app.activeDocument.layers[y+1],
ElementPlacement.PLACEAFTER)
}
}
}
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 66
ArtLayers
The collection of ArtLayer objects in a document or layer set.
Access through the Document
var layerRef = docRef.artLayers.add()
Properties
Property Value type What it is
length
parent
typename
Methods
Method Parameter type Returns What it does
add
()
getByName
(name)
.artLayers or LayerSet .artLayers collection. For example:
number
Read-only. The number of elements in the artLayers
collection.
Document
string
Read-only. The object's container.
Read-only. The class name of the referenced
artLayers object.
ArtLayer
Creates a new art layer in the
document and adds the new object to
this collection.
ArtLayer
string
Get the first element in the artLayers
collection with the provided name.
removeAll
()
Removes all elements from the
artLayers collection.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 67
BatchOptions
Options for running a batch operation using the Application. batch() method.
JavaScript only supports folders as sources for batch commands. Specify the batch source folder as the
inputFiles parameter of the Application. batch () method.
Properties
Property Value type What it is
destination
destinationFolder
errorFile
fileNaming
macintoshCompatible
BatchDestinationType
Folder
File
array of
FileNamingType
boolean
Read-write. The type of destination for the
processed files (default:
BatchDestinationType.NODESTINATION).
Read-write. The folder location for the processed
files.
Valid only when destination
BatchDestinationType.FOLDER.
=
Read-write. The file in which to log errors
encountered.
To display errors on the screen (and stop batch
processing when errors occur) leave blank.
Read-write. A list of file naming options
(maximum: 6).
Valid only when destination
BatchDestinationType.FOLDER.
=
Read-write. True to make the final file names
Macintosh compatible (default:
Valid only when destination
BatchDestinationType.FOLDER.
true).
=
overrideOpen
overrideSave
startingSerial
suppressOpen
boolean
boolean
number
boolean
Read-write. True to override action open
commands (default:
false).
Read-write. True to override save as action steps
with the specified destination (default:
Valid only when destination
BatchDestinationType.FOLDER or
SAVEANDCLOSE
.
=
false).
Read-write. The starting serial number to use in
naming files (default:
Valid only when destination
BatchDestinationType.FOLDER.
1).
=
Read-write. True to suppress the file open options
dialogs (default:
false).
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 68
Property Value type What it is (Continued)
suppressProfile
typename
unixCompatible
windowsCompatible
boolean
string
boolean
boolean
Read-write. True to suppress the color profile
warnings (default:
false).
Read-only. The class name of the referenced
batchOptions object.
Read-write. True to make the final file name Unix
compatible (default:
Valid only when destination
BatchDestinationType.FOLDER.
true).
=
Read-write. True to make the final file names
Windows compatible (default:
Valid only when destination
BatchDestinationType.FOLDER.
true).
=
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 69
BitmapConversionOptions
Options for converting an image to bitmap mode, using Document. changeMode () with
ChangeMode.Bitmap.
Convert color images to grayscale before converting the image to bitmap mode. See the
ArtLayer
Properties
Property Value type What it is
.desaturate () method.
angle
frequency
method
patternName
resolution
number [-180..180]
number [1.0..999.99]
BitmapConversionType
string
number
Read-write. The angle (in degrees) at which to
orient individual dots. See shape
Valid only when method
BitmapConversionType.HALFTONESCREEN.
=
.
Read-write. The number of printer dots (per inch) to
use.
Valid only when method
BitmapConversionType.HALFTONESCREEN.
=
Read-write. The conversion method to use (default:
BitmapConversionType.DIFFUSIONDITHER).
Read-write. The name of the pattern to use.
For information about pre-installed valid patterns,
see Adobe Photoshop CS4 Help on the bitmap
conversion command, or view the options availabe
in the Custom Color drop down box after choosing
the bitmap conversion command.
Valid only when method
BitmapConversionType.CUSTOMPATTERN
=
.
Read-write. The output resolution in pixels per inch
(default:
72.0).
shape
typename
BitmapHalfToneType
string
Read-write. The dot shape to use.
Valid only when method
BitmapConversionType.HALFTONESCREEN
=
Read-only. The class name of the referenced
bitmapConversionOptions object.
.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 70
BMPSaveOptions
Options for saving a document in BMP format using the Document. saveAs () method.
Properties
Property Value type What it is
alphaChannels
depth
flipRowOrder
osType
rleCompression
typename
boolean
BMPDepthType
boolean
OperatingSystem
boolean
string
Read-write. True to save the alpha channels.
Read-write. The number of bits per channel.
Read-write. True to write the image from top
to bottom (default:
Available only when osType
OperatingSystem.WINDOWS
false).
=
.
Read-write. The target OS.
(default:
OperatingSystem.WINDOWS).
Read-write. True to use RLE compression.
Available only when osType
OperatingSystem.WINDOWS
=
.
Read-only. The class name of the referenced
BMPSaveOptions object.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 71
CameraRAWOpenOptions
Options for opening a document in Camera RAW format using the Application. open () method.
Properties
Property Value type What it is
bitsPerChannel
blueHue
blueSaturation
brightness
chromaticAberrationBY
chromaticAberrationRC
colorNoiseReduction
colorSpace
contrast
exposure
greenHue
greenSaturation
luminanceSmoothing
BitsPerChannelType
number [-100..100]
number [-100..100]
number [0..150]
number [-100..100]
number [-100..100]
number [0..100]
ColorSpaceType
number [-50..100]
number [-4.0..4.0]
number [-100..100]
number [-100..100]
number [0..100]
Read-write. The number of bits per channel.
Read-write. The blue hue of the shot.
Read-write. The blue saturation of the shot.
Read-write. The brightness of the shot.
Read-write. The chromatic aberration B/Y of the
shot.
Read-write. The chromatic aberration R/C of the
shot
Read-write. The color noise reduction of the
shot.
Read-write. The colorspace for the image.
Read-write. The contrast of the shot.
Read-write. The exposure of the shot.
Read-write. The green hue of the shot.
Read-write. The green saturation of the shot.
Read-write. The luminance smoothing of the
shot.
redHue
redSaturation
resolution
saturation
settings
shadows
shadowTint
sharpness
size
temperature
number [-100..100]
number [-100..100]
number [1..999]
number [-100..100]
CameraRAWSettingsType
number [0..100]
number [-100..100]
number [0..100]
CameraRAWSize
number [2000..50000]
Read-write. The red hue of the shot.
Read-write. The red saturation of the shot.
Read-write. The resolution of the document in
pixels per inch.
Read-write. The saturation of the shot.
Read-write. The global settings for all Camera
RAW options. Default:
CameraRAWSettingsType.CAMERA.
Read-write. The shadows of the shot.
Read-write. The shadow tint of the shot.
Read-write. The sharpness of the shot.
Read-write. The size of the new document.
Read-write. The temperature of the shot.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 72
Property Value type What it is (Continued)
tint
typename
vignettingAmount
vignettingMidpoint
whiteBalance
number [-150..150]
string
number [-100..100]
number [-100..100]
WhiteBalanceType
Read-write. The tint of the shot.
Read-only. The class name of the referenced
cameraRAWOpenOptions object.
Read-write. The vignetting amount of the shot.
Read-write. The vignetting mid point of the
shot.
Read-write. The white balance options for the
image. These are lighting conditions that affect
color balance.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 73
Channel
Information about a color element in the image.
Access through the Document
by index or by name. For example, this accesses a channel object in the active document by name and
assigns an
var channelRef = app.activeDocument.channels.getByName("my channel");
channelRef.opacity = 22;
A channel is analogous to a plate in the printing process that applies a single color. The document’s color
mode determines the number of default channels; for example, an RGB document has three channels, red,
green, and blue. A color can also have an alpha channel, which stores selections as masks, or a spot
channel, which stores spot colors.
Properties
Property Value type What it is
color
histogram
opacity value:
.channels collection. You can access an individual channel object in this list
SolidColor
array of number
Read-write. The color of the channel.
Not valid when
kind = ChannelType.COMPONENT.
Read-only. A histogram of the color of the channel. The
array contains 256 members.
Not valid when
kind = ChannelType.COMPONENT. For
component channel histogram values, use the histogram
property of the Document
object instead.
kind
name
opacity
parent
typename
visible
Methods
Method Parameter type Returns What it does
duplicate
([targetDocument])
ChannelType
string
number [0..100]
Document
string
boolean
Document
Read-write. The type of the channel.
Read-write. The name of the channel.
Read-write. The opacity to use for alpha channels or the
solidity to use for spot channels.
Valid only when
SELECTEDAREA.
kind = ChannelType.MASKEDAREA or
Read-only. The containing document.
Read-only. The class name of the referenced channel
object.
Read-write. True if the channel is visible.
Channel
Duplicates the channel.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 74
Method Parameter type Returns What it does
merge
()
remove
()
Merges a spot channel into the
component channels.
Deletes the channel.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 75
Channels
The collection of Channel objects in a document.
Access through the Document
var channelRef = app.activeDocument.channels.add()
Properties
Property Value type What it is
length
parent
typename
Methods
Method Parameter type Returns What it does
add
()
getByName
(name)
.channels collection property. For example:
number
Read-only. The number of elements in the channels
collection.
Document
string
Read-only. The containing document.
Read-only. The class name of the referenced channels
object.
Channel
Channel
string
Creates a new channel object and
adds it to this collection.
Get the first element in the channels
collection with the provided name.
removeAll
()
Removes all alpha channel objects
from the
channels collection.
Channels sample script
The following script opens a file if one is not already open, and then writes a histogram report
(histogram.log) for the channels in the active document.
Note: This script contains a switch construction that uses a
requires an ending semicolon (;), as in the following sample:
break;
Histogram.jsx
// Function to activate all the channels according to the documents mode
// Takes a document reference for input
function TurnOnDocumentHistogramChannels(inDocument) {
// see how many channels we need to activate
var visibleChannelCount = 0
// based on the mode of the document
switch (inDocument.mode) {
break statement. The break statement
case DocumentMode.BITMAP:
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 76
case DocumentMode.GRAYSCALE:
case DocumentMode.INDEXEDCOLOR:
visibleChannelCount = 1
break;
case DocumentMode.DUOTONE:
visibleChannelCount = 2
break;
case DocumentMode.RGB:
case DocumentMode.LAB:
visibleChannelCount = 3
break;
case DocumentMode.CMYK:
visibleChannelCount = 4
break;
case DocumentMode.MULTICHANNEL:
default:
visibleChannelCount = inDocument.channels.length + 1
break;
}
// now get the channels to activate into a local array
var aChannelArray = new Array()
// index for the active channels array
var aChannelIndex = 0
for(var channelIndex = 0; channelIndex < inDocument.channels.length;
channelIndex++) {
if (channelIndex < visibleChannelCount) {
aChannelArray[aChannelIndex++] = inDocument.channels[channelIndex]
}
}
// now activate them
inDocument.activeChannels = aChannelArray
}
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// Set Adobe Photoshop CS4 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
// if there are no documents open then try to open a sample file
if (app.documents.length == 0) {
open(File(app.path + "/Samples/Fish.psd"))
}
// get a reference to the working document
var docRef = app.activeDocument
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 77
// create the output file
// first figure out which kind of line feeds we need
if ($.os.search(/windows/i) != -1) {
fileLineFeed = "Windows"
} else {
fileLineFeed = "Macintosh"
}
// create the output file accordingly
fileOut = new File("~/Desktop/Histogram.log")
fileOut.lineFeed = fileLineFeed
fileOut.open("w", "TEXT", "????")
// write out a header
fileOut.write("Histogram report for " + docRef.name)
// find out how many pixels I have
var totalCount = docRef.width.value * docRef.height.value
// more info to the out file
fileOut.write(" with a total pixel count of " + totalCount + "\n")
// channel indexer
var channelIndex = 0
// remember which channels are currently active
var myActiveChannels = app.activeDocument.activeChannels
// document histogram only works in these modes
if (docRef.mode == DocumentMode.RGB ||
docRef.mode == DocumentMode.INDEXEDCOLOR ||
docRef.mode == DocumentMode.CMYK) {
// activate the main channels so we can get the documents histogram
TurnOnDocumentHistogramChannels(docRef)
// Output the documents histogram
OutputHistogram(docRef.histogram, "Luminosity", fileOut)
}
// local reference to work from
var myChannels = docRef.channels
// loop through each channel and output the histogram
for (var channelIndex = 0; channelIndex < myChannels.length; channelIndex++) {
// the channel has to be visible to get a histogram
myChannels[channelIndex].visible= true
// turn off all the other channels
for (var secondaryIndex = 0; secondaryIndex < myChannels.length;
secondaryIndex++) {
if (channelIndex != secondaryIndex) {
myChannels[secondaryIndex].visible= false
}
}
// Use the function to dump the histogram
OutputHistogram(myChannels[channelIndex].histogram,
myChannels[channelIndex].name, fileOut)
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 78
}
// close down the output file
fileOut.close()
alert("Histogram file saved to: " + fileOut.fsName)
// reset the active channels
docRef.activeChannels = myActiveChannels
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
// Utility function that takes a histogram and name
// and dumps to the output file
function OutputHistogram(inHistogram, inHistogramName, inOutFile) {
// find ouch which count has the largest number
// I scale everything to this number for the output
var largestCount = 0
// a simple indexer I can reuse
var histogramIndex = 0
// see how many samples we have total
var histogramCount = 0
// search through all and find the largest single item
for (histogramIndex = 0; histogramIndex < inHistogram.length;
histogramIndex++) {
histogramCount += inHistogram[histogramIndex]
if (inHistogram[histogramIndex] > largestCount)
largestCount = inHistogram[histogramIndex]
}
// These should match
if (histogramCount != totalCount) {
alert("Something bad is happening!")
}
// see how much each "X" is going to count as
var pixelsPerX = largestCount / 100
// output this data to the file
inOutFile.write("One X = " + pixelsPerX + " pixels.\n")
// output the name of this histogram
inOutFile.write(inHistogramName + "\n")
// loop through all the items and output in the following format
// 001
// 002
for (histogramIndex = 0; histogramIndex < inHistogram.length;
histogramIndex++) {
// I need an extra "0" for this line item to keep everything in line
if (histogramIndex < 10)
inOutFile.write("0")
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 79
// I need an extra "0" for this line item to keep everything in line
if (histogramIndex < 100)
inOutFile.write("0")
// output the index to file
inOutFile.write(histogramIndex)
// some spacing to make it look nice
inOutFile.write(" ")
// figure out how many X’s I need
var outputX = inHistogram[histogramIndex] / largestCount * 100
// output the X’s
for (var a = 0; a < outputX; a++)
inOutFile.write("X")
inOutFile.write("\n")
}
inOutFile.write("\n")
}
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 80
CMYKColor
Defines a CMYK color, used in the SolidColor object.
See also GrayColor
Properties
Property Value type What it is
black
cyan
magenta
typename
yellow
, HSBColor , LabColor , NoColor , RGBColor
number [0.0..100.00]
number [0.0..100.00]
number [0.0..100.00]
string
Read-write. The black color value (as percent).
Read-write. The cyan color value (as percent).
Read-write. The magenta color value (as percent).
Read-only. The class name of the referenced CMYKColor
object.
number [0.0..100.00]
Read-write. The yellow color value (as percent).
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 81
ColorSampler
A color sampler for a document. Access through the Document. colorSamplers collection. For example:
var colorSamplerRef = app.activeDocument.colorSamplers[0];
var currentColor = colorSamplerRef.color;
Note: For additional information about color samplers, see Adobe Photoshop CS4 help on the Color
SamplerTool.
Properties
Property Value type What it is
color
position
parent
typename
Methods
Method Parameter type Returns What it does
move
remove
(position)
()
SolidColor
array of
UnitValue
Document
string
array of
UnitValue
Read-only. The color of the color sampler.
Read-only. The position of the color sampler in the
document. The array (x,y) represents the horizontal and
vertical location of the count item.
Read-only. The containing document.
Read-only. The class name of the referenced ColorSampler
object.
Moves the color sampler to a new location
in the document.
position parameter (x,y) represents
The
the new horizontal and vertical locations
of the moved color sampler.
Deletes the ColorSampler object.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 82
ColorSamplers
The collection of ColorSampler objects in a document. Access through the Document. colorSamplers
collection property. For example:
app.activeDocument.colorSamplers.removeAll()
Properties
Property Value type What it is
length
parent
typename
Methods
Method Parameter type Returns What it does
add
removeAll
(position)
()
number
Document
string
array of UnitValue
Read-only. The number of elements in the
ColorSamplers collection.
Read-only. The containing document.
Read-only. The class name of the referenced
ColorSamplers object.
ColorSampler
Creates a new color sampler object
and adds it to this collection.
position parameter (x,y)
The
represents the new horizontal and
vertical locations of the moved color
sampler.
Removes all ColorSampler objects
from the
ColorSamplers collection.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 83
ContactSheetOptions
Options for creating a contact sheet with the Application. makeContactSheet () method.
Properties
Property Value type What it is
acrossFirst
bestFit
caption
columnCount
flatten
font
fontSize
height
horizontal
boolean
boolean
boolean
number[1..100]
boolean
GalleryFontType
number
number [0..29000]
number
Read-write. True to place the images horizontally
(left to right, then top to bottom) first (default:
true).
Read-write. True to rotate images for the best fit
(default:
false).
Read-write. True to use the filename as a caption for
the image (default:
true).
Read-write. The number of columns to include
(default:
5).
Read-write. True to flatten all layers in the final
document (default:
true).
Read-write. The font used for the caption (default:
GalleryFontType.ARIAL).
Read-write. The font size to use for the caption
(default:
12).
Read-write. The height (in pixels) of the resulting
document (default:
720).
Read-write. The horizontal spacing (in pixels)
between images (default:
1).
mode
resolution
rowCount
typename
useAutoSpacing
vertical
width
NewDocumentMode
number [35..1200]
number [1..100]
string
boolean
number [0..29000]
number [100..29000]
Read-write. The document color mode (default:
NewDocumentMode.RGB).
Read-write. The resolution of the document in pixels
per inch (default:
72.0).
Read-write. The number of rows to use (default: 6 ).
Read-only. The class name of the referenced
contactSheetOptions object.
Read-write. True to auto space the images (default:
true).
Read-write. The vertical spacing (in pixels) between
images (default:
Valid only when
1).
useAutoSpacing = false.
Read-write. The width (in pixels) of the resulting
document (default:
576).
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 84
CountItem
A counted item in a document. Access through the Document. countItems collection. See the
Document
Note: This feature is available in the Extended Version only.
For additional information about count items, see Adobe Photoshop CS4 help on the Count Tool.
Properties
Property Value type What it is
.autoCount () method.
position
parent
typename
Methods
Method Parameter type Returns What it does
remove
()
array of
UnitValue
Document
string
Read-only. The position of the count item in the document.
Read-only. The containing document.
Read-only. The class name of the referenced CountItem
object.
Deletes the CountItem object.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 85
CountItems
The collection of CountItem objects in the document.
Access through the Document
app.activeDocument.countItems.removeAll()
Note: This feature is available in the Extended Version only.
Properties
Property Value type What it is
length
parent
typename
Methods
Method Parameter type Returns What it does
add
(position)
.countItems collection property. For example:
number
Read-only. The number of elements in the CountItems
collection.
Document
string
Read-only. The containing document.
Read-only. The class name of the referenced CountItems
object.
array of UnitValue
CountItem
Creates a new count item object and
adds it to this collection.
getByName
(name)
removeAll
()
string
CountItem
Parameter
position (x,y) represents
the horizontal and vertical positions,
respectively, of the
CountItem object.
Get the first element in the
CountItems collection with the
provided name.
Removes all CountItem objects from
the
CountItems collection .
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 86
DCS1_SaveOptions
Options for saving a CMYK document in DCS1 format using the Document. saveAs () method.
Properties
Property Value type What it is
dCS
embedColorProfile
encoding
halftoneScreen
interpolation
preview
transferFunction
typename
vectorData
DCSType
boolean
SaveEncoding
boolean
boolean
Preview
boolean
string
boolean
Read-write. (default: DCSType.COLORCOMPOSITE ).
Read-write. True to embed the color profile in the
document
Read-write. The type of encoding to use for document
(default:
SaveEncoding.BINARY).
Read-write. True to include halftone screen (default:
false).
Read-write. True to use image interpolation (default:
false)
Read-write. The type of preview (default:
Preview.MACOSEIGHTBIT).
Read-write. True to include the Transfer functions to
compensate for dot gain between the image and film
(default:
false).
Read-only. The class name of the referenced
DCS1_SaveOptions object.
Read-write. True to include vector data.
Valid only if the document includes vector data
(unrasterized text).
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 87
DCS2_SaveOptions
Options for saving a CMYK document in DCS2 format using the Document. saveAs () method.
Properties
Property Value type What it is
dCS
embedColorProfile
encoding
halftoneScreen
interpolation
multiFileDCS
preview
spotColors
transferFunction
DCSType
boolean
SaveEncoding
boolean
boolean
boolean
Preview
boolean
boolean
Read-write. The type of composite file to create
(default:
DCSType.NOCOMPOSITE).
Read-write. True to embed the color profile in the
document.
Read-write. The type of encoding to use (default:
SaveEncoding.BINARY).
Read-write. True to include the halftone screen
(default:
false).
Read-write. True to use image interpolation (default:
false).
Read-write. True to save color channels as multiple
files or a single file (default:
false).
Read-write. The preview type (default:
Preview.MACOSEIGHTBIT).
Read-write. True to save spot colors.
Read-write. True to include the Transfer functions to
compensate for dot gain between the image and film
(default:
false).
typename
vectorData
string
boolean
Read-only. The class name of the referenced
DCS2_SaveOptions object.
Read-write. True to include vector data.
Valid only if the document includes vector data
(unrasterized text).
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 88
DICOMOpenOptions
Options for opening a document in DICOM format using the Application. open () method.
Note: This feature is available in the Extended Version only.
Properties
Property Value type What it is
anonymize
columns
reverse
rows
showOverlays
typename
windowLevel
windowWidth
boolean
number
boolean
number
boolean
string
number
number
Read-write. True to make the patient
information anonymous.
Read-write. Number of columns in n-up
configuration.
Read-write. True to reverse (invert) the image.
Read-write. The number of rows in n-up
configuration.
Read-write. True to show overlays.
Read-only. The class name of the referenced
DICOMOpenOptions object.
Read-write. The contrast of the image in
Houndsfield units.
Read-write. The brightness of the image in
Houndsfield units.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 89
Document
The active containment object for layers and all other objects in the script; the basic canvas for the file.
● Access the object for the currently active document through Application. activeDocument.
● You can access other documents, or iterate through all open documents using the list in the
Application
Documents
● Create documents programmatically using the Documents. add () method.
.documents collection. You can access individual documents in the list by index, or use
.getByName () to retrieve them by name.
See Document sample script
Note: In Adobe Photoshop CS4, a document can also be referred to as an image or a canvas.
Properties
Property Value type What it is
activeChannels
activeHistoryBrushSource
activeHistoryState
activeLayer
artLayers
backgroundLayer
and the Documents collection object for examples.
● The term image refers to the entire document and its contents. You can trim or crop an image.
You resize an image using the
● The term canvas refers to the space in which the document sits on the screen. You can rotate or
flip the canvas. You resize the canvas using the
array of Channel
HistoryState
resizeImage() method.
resizeCanvas() method.
Read-write. The selected channels.
Read-write. The history state to use with the
history brush.
HistoryState
ArtLayer or
LayerSet
ArtLayers
ArtLayer
Read-write. The selected HistoryState object.
Read-write. The selected layer.
Read-only. The art layers collection.
Read-only. The background layer of the
document.
bitsPerChannel
channels
colorProfileName
colorProfileType
colorSamplers
componentChannels
BitsPerChannelType
Channels
string
ColorProfileType
ColorSamplers
array of Channel
Read-write. The number of bits per channel.
Read-only. The channels collection.
Read-write. The name of the color profile.
Valid only when colorProfileType
ColorProfile.CUSTOM
or WORKING .
=
Read-write. Whether the document uses the
working color profile, a custom profile, or no
profile.
Read-only. The current color samplers
associated with this document.
Read-only. The color channels that make up
the document; for instance, the Red, Green,
and Blue channels for an RGB document.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 90
Property Value type What it is (Continued)
countItems
fullName
height
histogram
historyStates
info
layerComps
layers
CountItems
File
UnitValue
array of number
HistoryStates
DocumentInfo
LayerComps
Layers
Read-only. The current count items.
Note: For additional information about count
items, see Adobe Photoshop CS4 help
on the Count Tool.
Read-only. The full path name of the
document.
Read-only. The height of the document (unit
value).
Read-only. A histogram showing the number
of pixels at each color intensity level for the
composite channel. The array c ontains 256
members.
Valid only when mode
CMYK; or INDEXEDCOLOR.
= DocumentMode.RGB,
Read-only. The history states collection.
Read-only. Metadata about the document.
Read-only. The layer compositions collection.
Read-only. The layers collection.
layerSets
managed
measurementScale
mode
name
parent
path
pathItems
pixelAspectRatio
printSettings
LayerSets
boolean
MeasurementScale
DocumentMode
string
Application
File
PathItems
number
[0.100..10.000]
DocumentPrintSettin
gs
Read-only. The layer set collection.
Read-only. True if the document a is workgroup
document.
Read-only. The measurement scale for the
document.
Note: The measurement scale feature is
available in the Extended version only.
Read-only. The color profile.
Read-only. The document's name.
Read-only. The application object that contains
this document.
Read-only. The path to the document.
Read-only. The path items collection.
Read-write. The (custom) pixel aspect ratio to
use.
Read-only. The print settings for the document.
quickMaskMode
boolean
Read-write. True if the document is in Quick
Mask mode.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 91
Property Value type What it is (Continued)
resolution
saved
selection
typename
width
xmpMetadata
number
boolean
Selection
string
UnitValue
xmpMetadata
Read-only. The document’s resolution (in pixels
per inch).
Read-only. True if the document has been
saved since the last change.
Read-only. The selected area of the document.
Read-only. The class name of the Document
object.
Read-only. The width of the document (unit
value).
Read-only. XMP metadata for the document.
Camera RAW settings for the image are stored
here for example.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 92
Methods
Method Parameter type Returns What it does
autoCount
(channel,
threshold)
changeMode
(destinationMode
[, options])
close
([saving])
convertProfile
(destinationProfile,
intent
[, blackPointCompensation]
[, dither])
Channel
number
ChangeMode
BitmapConversionOptions
or
IndexedConversionOptions
SaveOptionsType
string
Intent
boolean
boolean
Counts the number of objects in a
document. Available in the Extended
Version only.
Creates a CountItem
object for each
object counted.
For additional information about how to
set up objects to count, see the Count Tool
in the Adobe Photoshop CS4 Help
Changes the color profile of the
document.
Closes the document. If any changes have
been made, the script presents an alert
with three options: save, do not save,
prompt to save. The optional parameter
specifies a selection in the alert box
(default:
PROMPTTOSAVECHANGES
SaveOptionsType.
).
Changes the color profile.
destinationProfile
The
parameter must
be either a string that names the color
mode or
Working Gray, Lab Color (meaning one
Working RGB, Working CMYK,
of the working color spaces or Lab color).
crop
(bounds
[, angle]
[, width]
[, height])
duplicate
([name ]
[, mergeLayersOnly]
)
array of 4 UnitValue
number
UnitValue
UnitValue
string
boolean
Document
Crops the document. The bounds
parameter is an array of four coordinates
for the region remaining after cropping,
[left, top, right, bottom].
Creates a duplicate of the document
object.
The optional parameter
name provides the
name for the duplicated document.
The optional parameter
mergeLayersOnly indicates whether to
only duplicate merged layers.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 93
Method Parameter type Returns What it does (Continued)
exportDocument
(exportIn
[, exportAs]
[, options])
flatten
()
flipCanvas
(direction)
importAnnotations
(file)
mergeVisibleLayers
()
paste
([intoSelection])
print
([postScriptEncoding]
[, sourceSpace]
[, printSpace]
[, intent]
[blackPointCompensation])
File
ExportType
ExportOptionsIllustrator
—or—
ExportOptionsSaveForWeb
Direction
File
boolean
PrintEncoding
SourceSpaceType
string
Intent
boolean
ArtLayer
Exports the paths in the document to an
Illustrator file, or exports the document to
a file with Web or device viewing
optimizations.
This is equivalent to choosing File >
Export > Paths To Illustrator, or File >
Save For Web and Devices.
Flattens all layers in the document.
Flips the image within the canvas in the
specified direction.
Imports annotations into the document.
Flattens all visible layers in the document.
Pastes the contents of the clipboard into
the document. If the optional argument is
set to
true and a selection is active, the
contents are pasted into the selection.
Prints the document.
printSpace specifies the color space for
the printer. Valid values are
is, the same as the source); or
, Working CMYK , Working Gray , Lab
RGB
Color (meaning one of the working color
nothing (that
Working
spaces or Lab color); or a string specifying
a specific colorspace (default:
nothing).
printOneCopy
()
rasterizeAllLayers
()
recordMeasurements
([source]
[, dataPoints])
resizeCanvas
([width]
[, height]
[, anchor])
resizeImage
([width]
[, height]
[, resolution]
[, resampleMethod])
MeasurementSource
array of string
UnitValue
UnitValue
AnchorPosition
UnitValue
UnitValue
number
ResampleMethod
Print one copy of the document.
Rasterizes all layers.
Record measurements of document.
Changes the size of the canvas to display
more or less of the image but does not
change the image size. See resizeImage
Changes the size of the image.
.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 94
Method Parameter type Returns What it does (Continued)
revealAll
()
rotateCanvas
(angle)
save
()
saveAs
(saveIn
[, options]
[, asCopy]
[, extensionType])
number
File
object (see description)
boolean
Extension
Expands the document to show clipped
sections.
Rotates the canvas (including the image)
in clockwise direction.
Saves the document.
Saves the document in a specific format.
Specify the save options appropriate to
the format by passing one of these
objects:
BMPSaveOptions
DCS1_SaveOptions
DCS2_SaveOptions
EPSSaveOptions
GIFSaveOptions
JPEGSaveOptions
PDFSaveOptions
PhotoshopSaveOptions
PICTFileSaveOptions
PICTResourceSaveOptions
PixarSaveOptions
PNGSaveOptions
RawSaveOptions
SGIRGBSaveOptions
TargaSaveOptions
TiffSaveOptions
splitChannels
()
suspendHistory
(historyString
javaScriptString)
trap
(width)
trim
([type]
[, top]
[, left]
[, bottom]
[, right])
string
string
number
TrimType
boolean
boolean
boolean
boolean
array of
Document
Splits the document channels into
separate images.
Provides a single entry in history states for
the entire script provided by
javaScriptString. Allows a single undo
for all actions taken in the script.
historyString parameter provides
The
the string to use for the history state.
javaScriptString parameter
The
provides a string of JavaScript code to
excute while history is suspended.
Applies trapping to a CMYK document.
Valid only when
DocumentMode.CMYK
docRef.mode =
.
Trims the transparent area around the
image on the specified sides of the canvas.
Default is
true for all Boolean parameters.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 95
Document sample script
The following script creates a document that contains two images (a sunflower and a duck) obtained from
the Adobe Photoshop CS4 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 and pastes the sunflower into the selection.
● Inverts the selection and pastes the duck into the lower part of the document.
● Positions the sunflower 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 CS4 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
var mergedDoc = app.documents.add(duckDoc.width, duckDoc.height * 2,
duckDoc.resolution, "FlowerOverDuck")
// Copy the flower to the top; make it the active document so we can manipulate it
app.activeDocument = flowerDoc
flowerDoc.activeLayer.copy()
//Paste the flower to the merged document, making the merged document active
app.activeDocument = mergedDoc
// Select a square area at the top of the new document
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 96
var selRegion = Array(Array(0, 0),
Array(mergedDoc.width.value, 0),
Array(mergedDoc.width.value, mergedDoc.height.value / 2),
Array(0, mergedDoc.height.value / 2),
Array(0, 0))
// Create the selection
mergedDoc.selection.select(selRegion)
//Paste in the flower
mergedDoc.paste(TRUE)
// do the same thing for the duck
app.activeDocument = duckDoc
duckDoc.activeLayer.copy()
app.activeDocument = mergedDoc
mergedDoc.selection.select(selRegion)
// Inverting the selection so the bottom of the document is now selected
mergedDoc.selection.invert()
// Paste the duck
mergedDoc.paste(TRUE)
// get rid of our originals without modifying them
duckDoc.close(SaveOptions.DONOTSAVECHANGES)
flowerDoc.close(SaveOptions.DONOTSAVECHANGES)
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 97
DocumentPrintSettings
The print settings for a document. New for Photoshop CS4.
Properties
Property Value type What it is
backgroundColor
bleedWidth
caption
centerCropMarks
colorBars
copies
cornerCropMarks
colorHandling
activePrinter
flip
hardProof
interpolate
labels
mapBlack
negative
SolidColor
UnitValue
boolean
boolean
boolean
number
boolean
PrintColorHandling
string
boolean
boolean
boolean
boolean
boolean
boolean
Read-write. Background color of page.
Read-write. Bleed width
Read-write. Print the caption found in FileInfo.
Read-write. Print center crop marks.
Read-write. Print color calibration bars.
Read-write. Number of copies to print.
Read-write. Print corner crop marks.
Read-only. Color handling.
Read-write. The currently active printer.
Read-write. Flip the image horizontally.
Read-write. Print a hard proof.
Read-write.
Read-write. Prints the document title.
Read-write. Map blacks.
Read-write. Invert the image colors.
renderIntent
posX
posY
printBorder
printSelected
printSpace
Intent
UnitValue
UnitValue
UnitValue
boolean
string
Read-write. Color conversion intent when print
space is different from the source space.
Read-only. The x position of the image on
page.
Read-only. The y position of the image on
page.
Read-write. The width of the print border.
Read-write. Print the selected area of the
document.
Read-write. color space for printer. Can be
nothing (meaning same as source); 'Working
RGB', 'Working CMYK', 'Working Gray', 'Lab
Color' (meaning one of the working spaces or
Lab color); or a string specifying a specific
colorspace (default is same as source)
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 98
Property Value type What it is (Continued)
registrationMarks
scale
vectorData
boolean
number
boolean
Read-write. Print registration marks.
Read-only. Scale of image on page.
Read-write. Include vector data.
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 99
Methods
Method Parameter type Returns What it does
setPagePosition
(docPosition,
posX,
posY,
scale)
DocPositionStyle
Set the position of the image on the page.
UnitValue
UnitValue
number
Adobe Photoshop CS4
JavaScript Scripting Reference JavaScript Object Reference 100
DocumentInfo
Metadata about a document object.
Access through the Document
copyrighted properties:
These values can be set interactively by choosing File > File Info.
Properties
Property Value type What it is
author
authorPosition
caption
captionWriter
category
city
.info property. For example, the following sets the author, caption , and
var docRef = open(fileList[i])
// set the file info
docRef.info.author = "Mr. Adobe programmer"
docRef.info.caption = "Adobe Photo shoot"
docRef.info.copyrighted = CopyrightedType.COPYRIGHTEDWORK
string
string
string
string
string
string
Read-write.
Read-write.
Read-write.
Read-write.
Read-write.
Read-write.
copyrighted
copyrightNotice
country
creationDate
credit
exif
headline
instructions
jobName
keywords
ownerUrl
CopyrightedType
string
string
string
string
array of array [tag data ]
string
string
string
array of string
string
Read-write. The copyrighted status.
Read-write.
Read-write.
Read-write.
Read-write.
Read-only. Camera data that includes
camera settings used when the image
was taken.
Each array member is a tag pair, an array
of [tag, tag_data ]; for example,
"camera" "Cannon"].
[
Read-write.
Read-write.
Read-write.
Read-write. A list of keywords that can
identify the document or its contents.
Read-write.