Photoshop Javascript Ref 2020
Photoshop Javascript Ref 2020
1 Introduction ............................................................................................................................... 32
JavaScript support in Adobe Photoshop.............................................................................................................................32
Executing scripts ....................................................................................................................................................................33
Installing scripts ...............................................................................................................................................................33
Executing other scripts ..................................................................................................................................................33
Startup scripts .........................................................................................................................................................................33
Object model usage and naming...........................................................................................................................................34
2 JavaScript Object Reference ..................................................................................................... 35
Object descriptions......................................................................................................................................................................35
Properties notation ...............................................................................................................................................................35
displayDialogs.................................................................................................................................................................35
Methods notation ..................................................................................................................................................................35
crop.....................................................................................................................................................................................36
ActionDescriptor ..........................................................................................................................................................................37
Properties..................................................................................................................................................................................37
count ..................................................................................................................................................................................37
typename .........................................................................................................................................................................37
Methods ....................................................................................................................................................................................37
clear ....................................................................................................................................................................................37
erase ...................................................................................................................................................................................37
fromStream......................................................................................................................................................................37
getBoolean.......................................................................................................................................................................37
getClass .............................................................................................................................................................................37
getData..............................................................................................................................................................................37
getDouble ........................................................................................................................................................................37
getEnumerationType ...................................................................................................................................................37
getEnumerationValue..................................................................................................................................................37
getInteger.........................................................................................................................................................................37
getKey................................................................................................................................................................................37
getLargeInteger .............................................................................................................................................................38
getList ................................................................................................................................................................................38
getObjectType................................................................................................................................................................38
getObjectValue...............................................................................................................................................................38
getPath ..............................................................................................................................................................................38
getReference ...................................................................................................................................................................38
getString ...........................................................................................................................................................................38
getType .............................................................................................................................................................................38
getUnitDoubleType ......................................................................................................................................................38
getUnitDoubleValue.....................................................................................................................................................38
hasKey................................................................................................................................................................................38
isEqual................................................................................................................................................................................38
putBoolean ......................................................................................................................................................................38
putClass.............................................................................................................................................................................38
putData .............................................................................................................................................................................38
putDouble ........................................................................................................................................................................38
3
Adobe Photoshop
JavaScript Scripting Reference 4
putEnumerated ..............................................................................................................................................................38
putInteger ........................................................................................................................................................................39
putLargeInteger .............................................................................................................................................................39
putList ................................................................................................................................................................................39
putObject..........................................................................................................................................................................39
putPath..............................................................................................................................................................................39
putReference...................................................................................................................................................................39
putString...........................................................................................................................................................................39
putUnitDouble................................................................................................................................................................39
toStream ...........................................................................................................................................................................39
ActionList.........................................................................................................................................................................................40
Properties..................................................................................................................................................................................40
count ..................................................................................................................................................................................40
typename .........................................................................................................................................................................40
Methods ....................................................................................................................................................................................40
clear ....................................................................................................................................................................................40
getBoolean.......................................................................................................................................................................40
getClass .............................................................................................................................................................................40
getData..............................................................................................................................................................................40
getDouble ........................................................................................................................................................................40
getEnumerationType ...................................................................................................................................................40
getEnumerationValue..................................................................................................................................................40
getInteger.........................................................................................................................................................................40
getLargeInteger .............................................................................................................................................................41
getList ................................................................................................................................................................................41
getObjectType................................................................................................................................................................41
getObjectValue...............................................................................................................................................................41
getPath ..............................................................................................................................................................................41
getReference ...................................................................................................................................................................41
getString ...........................................................................................................................................................................41
getType .............................................................................................................................................................................41
getUnitDoubleType ......................................................................................................................................................41
getUnitDoubleValue.....................................................................................................................................................41
putBoolean ......................................................................................................................................................................41
putClass.............................................................................................................................................................................41
putData .............................................................................................................................................................................41
putDouble ........................................................................................................................................................................41
putEnumerated ..............................................................................................................................................................41
putInteger ........................................................................................................................................................................41
putLargeInteger .............................................................................................................................................................41
putList ................................................................................................................................................................................41
putObject..........................................................................................................................................................................42
putPath..............................................................................................................................................................................42
putReference...................................................................................................................................................................42
putString...........................................................................................................................................................................42
putUnitDouble................................................................................................................................................................42
ActionReference ...........................................................................................................................................................................43
Properties..................................................................................................................................................................................43
typename .........................................................................................................................................................................43
Methods ....................................................................................................................................................................................43
getContainer ...................................................................................................................................................................43
Adobe Photoshop
JavaScript Scripting Reference 5
getDesiredClass..............................................................................................................................................................43
getEnumeratedType.....................................................................................................................................................43
getEnumeratedValue ...................................................................................................................................................43
getForm.............................................................................................................................................................................43
getIdentifier.....................................................................................................................................................................43
getIndex............................................................................................................................................................................43
getName ...........................................................................................................................................................................43
getOffset ...........................................................................................................................................................................43
getProperty......................................................................................................................................................................43
putClass.............................................................................................................................................................................44
putEnumerated ..............................................................................................................................................................44
putIdentifier.....................................................................................................................................................................44
putIndex............................................................................................................................................................................44
putName...........................................................................................................................................................................44
putOffset...........................................................................................................................................................................44
putProperty......................................................................................................................................................................44
Application .....................................................................................................................................................................................45
Properties..................................................................................................................................................................................45
activeDocument.............................................................................................................................................................45
backgroundColor...........................................................................................................................................................45
build....................................................................................................................................................................................45
cloudWorkAreaDirectory ............................................................................................................................................45
colorSettings ...................................................................................................................................................................45
currentTool ......................................................................................................................................................................45
displayDialogs.................................................................................................................................................................45
documents .......................................................................................................................................................................45
fonts....................................................................................................................................................................................45
foregroundColor ............................................................................................................................................................45
freeMemory .....................................................................................................................................................................46
locale ..................................................................................................................................................................................46
macintoshFileTypes......................................................................................................................................................46
measurementLog ..........................................................................................................................................................46
name...................................................................................................................................................................................46
notifiers .............................................................................................................................................................................46
notifiersEnabled .............................................................................................................................................................46
path.....................................................................................................................................................................................46
playbackDisplayDialogs ..............................................................................................................................................46
playbackParameters .....................................................................................................................................................46
preferences ......................................................................................................................................................................46
preferencesFolder .........................................................................................................................................................46
recentFiles ........................................................................................................................................................................46
scriptingBuildDate ........................................................................................................................................................46
scriptingVersion .............................................................................................................................................................46
systemInformation........................................................................................................................................................46
typename .........................................................................................................................................................................46
version ...............................................................................................................................................................................47
windowsFileTypes.........................................................................................................................................................47
Methods ....................................................................................................................................................................................47
batch ..................................................................................................................................................................................47
beep....................................................................................................................................................................................47
bringToFront ...................................................................................................................................................................47
Adobe Photoshop
JavaScript Scripting Reference 6
changeProgressText .....................................................................................................................................................47
charIDToTypeID..............................................................................................................................................................47
compareWithNumbers ................................................................................................................................................47
doAction ...........................................................................................................................................................................48
doForcedProgress .........................................................................................................................................................48
doProgress .......................................................................................................................................................................48
doProgressSegmentTask ............................................................................................................................................48
doProgressSubTask.......................................................................................................................................................49
doProgressTask ..............................................................................................................................................................49
eraseCustomOptions....................................................................................................................................................49
executeAction.................................................................................................................................................................49
executeActionGet..........................................................................................................................................................49
featureEnabled ...............................................................................................................................................................49
getCustomOptions........................................................................................................................................................49
isQuicktimeAvailable....................................................................................................................................................49
load .....................................................................................................................................................................................49
makeContactSheet........................................................................................................................................................50
makePDFPresentation .................................................................................................................................................50
makePhotoGallery.........................................................................................................................................................50
makePhotomerge..........................................................................................................................................................50
makePicturePackage ....................................................................................................................................................50
open ...................................................................................................................................................................................50
openDialog ......................................................................................................................................................................50
purge..................................................................................................................................................................................51
putCustomOptions .......................................................................................................................................................51
refresh................................................................................................................................................................................51
refreshFonts.....................................................................................................................................................................51
runMenuItem ..................................................................................................................................................................51
showColorPicker ............................................................................................................................................................51
stringIDToTypeID...........................................................................................................................................................51
togglePalettes.................................................................................................................................................................51
toolSupportsBrushes....................................................................................................................................................51
(tool) ...................................................................................................................................................................................51
toolSupportsBrushPresets..........................................................................................................................................51
(tool) ...................................................................................................................................................................................51
typeIDToCharID..............................................................................................................................................................51
typeIDToStringID ...........................................................................................................................................................52
updateProgress ..............................................................................................................................................................52
ArtLayer............................................................................................................................................................................................55
Properties..................................................................................................................................................................................55
allLocked...........................................................................................................................................................................55
blendMode.......................................................................................................................................................................55
bounds...............................................................................................................................................................................55
boundsNoEffects ...........................................................................................................................................................55
fillOpacity..........................................................................................................................................................................55
filterMaskDensity ...........................................................................................................................................................55
filterMaskFeather...........................................................................................................................................................55
grouped ............................................................................................................................................................................55
isBackgroundLayer........................................................................................................................................................55
kind .....................................................................................................................................................................................55
layerMaskDensity...........................................................................................................................................................56
Adobe Photoshop
JavaScript Scripting Reference 7
layerMaskFeather ..........................................................................................................................................................56
linkedLayers.....................................................................................................................................................................56
name...................................................................................................................................................................................56
opacity ...............................................................................................................................................................................56
parent.................................................................................................................................................................................56
pixelsLocked....................................................................................................................................................................56
positionLocked...............................................................................................................................................................56
textItem.............................................................................................................................................................................56
transparentPixelsLocked.............................................................................................................................................56
typename .........................................................................................................................................................................56
vectorMaskDensity........................................................................................................................................................56
vectorMaskFeather .......................................................................................................................................................56
visible .................................................................................................................................................................................56
xmpMetadata..................................................................................................................................................................56
Methods ....................................................................................................................................................................................57
adjustBrightnessContrast ...........................................................................................................................................57
adjustColorBalance .......................................................................................................................................................57
adjustCurves....................................................................................................................................................................57
adjustLevels .....................................................................................................................................................................57
applyAddNoise...............................................................................................................................................................57
applyAverage..................................................................................................................................................................57
applyBlur...........................................................................................................................................................................57
applyBlurMore ................................................................................................................................................................57
applyClouds.....................................................................................................................................................................57
applyCustomFilter.........................................................................................................................................................57
applyDeInterlace............................................................................................................................................................58
applyDespeckle ..............................................................................................................................................................58
applyDifferenceClouds................................................................................................................................................58
applyDiffuseGlow ..........................................................................................................................................................58
applyDisplace..................................................................................................................................................................58
applyDustAndScratches..............................................................................................................................................58
applyGaussianBlur.........................................................................................................................................................58
applyGlassEffect.............................................................................................................................................................58
applyHighPass ................................................................................................................................................................58
applyLensBlur .................................................................................................................................................................59
applyLensFlare................................................................................................................................................................59
applyMaximum ..............................................................................................................................................................59
applyMedianNoise ........................................................................................................................................................59
applyMinimum ...............................................................................................................................................................60
applyMotionBlur ............................................................................................................................................................60
applyNTSC........................................................................................................................................................................60
applyOceanRipple .........................................................................................................................................................60
applyOffset.......................................................................................................................................................................60
applyPinch .......................................................................................................................................................................60
applyPolarCoordinates................................................................................................................................................60
applyRadialBlur ..............................................................................................................................................................60
applyRipple......................................................................................................................................................................60
applySharpen..................................................................................................................................................................60
applySharpenEdges......................................................................................................................................................60
applySharpenMore .......................................................................................................................................................60
applyShear .......................................................................................................................................................................61
Adobe Photoshop
JavaScript Scripting Reference 8
applySmartBlur...............................................................................................................................................................61
applySpherize .................................................................................................................................................................61
applyStyle.........................................................................................................................................................................61
applyTextureFill..............................................................................................................................................................61
applyTwirl.........................................................................................................................................................................61
applyUnSharpMask.......................................................................................................................................................61
applyWave........................................................................................................................................................................61
applyZigZag.....................................................................................................................................................................61
autoContrast....................................................................................................................................................................61
autoLevels ........................................................................................................................................................................61
clear ....................................................................................................................................................................................62
copy ....................................................................................................................................................................................62
cut........................................................................................................................................................................................62
desaturate ........................................................................................................................................................................62
duplicate ...........................................................................................................................................................................62
equalize .............................................................................................................................................................................62
invert ..................................................................................................................................................................................62
link.......................................................................................................................................................................................62
merge.................................................................................................................................................................................62
mixChannels....................................................................................................................................................................63
move...................................................................................................................................................................................63
photoFilter .......................................................................................................................................................................63
posterize ...........................................................................................................................................................................63
rasterize.............................................................................................................................................................................63
remove...............................................................................................................................................................................63
resize ..................................................................................................................................................................................64
rotate..................................................................................................................................................................................64
selectiveColor..................................................................................................................................................................64
shadowHighlight ...........................................................................................................................................................64
threshold...........................................................................................................................................................................64
translate ............................................................................................................................................................................64
unlink .................................................................................................................................................................................64
ArtLayers..........................................................................................................................................................................................67
Properties..................................................................................................................................................................................67
length.................................................................................................................................................................................67
parent.................................................................................................................................................................................67
typename .........................................................................................................................................................................67
Methods ....................................................................................................................................................................................67
add ......................................................................................................................................................................................67
getByName ......................................................................................................................................................................67
removeAll .........................................................................................................................................................................67
BatchOptions .................................................................................................................................................................................68
Properties..................................................................................................................................................................................68
destination .......................................................................................................................................................................68
destinationFolder ..........................................................................................................................................................68
errorFile .............................................................................................................................................................................68
fileNaming........................................................................................................................................................................68
macintoshCompatible .................................................................................................................................................68
overrideOpen..................................................................................................................................................................68
overrideSave....................................................................................................................................................................68
startingSerial ...................................................................................................................................................................68
Adobe Photoshop
JavaScript Scripting Reference 9
suppressOpen.................................................................................................................................................................68
suppressProfile ...............................................................................................................................................................69
typename .........................................................................................................................................................................69
unixCompatible..............................................................................................................................................................69
windowsCompatible ....................................................................................................................................................69
BitmapConversionOptions .......................................................................................................................................................70
Properties..................................................................................................................................................................................70
angle...................................................................................................................................................................................70
frequency..........................................................................................................................................................................70
method..............................................................................................................................................................................70
patternName ...................................................................................................................................................................70
resolution..........................................................................................................................................................................70
shape..................................................................................................................................................................................70
typename .........................................................................................................................................................................70
BMPSaveOptions ..........................................................................................................................................................................71
Properties..................................................................................................................................................................................71
alphaChannels ................................................................................................................................................................71
depth..................................................................................................................................................................................71
flipRowOrder ...................................................................................................................................................................71
osType................................................................................................................................................................................71
rleCompression ..............................................................................................................................................................71
typename .........................................................................................................................................................................71
CameraRAWOpenOptions ........................................................................................................................................................72
Properties..................................................................................................................................................................................72
bitsPerChannel ...............................................................................................................................................................72
blueHue.............................................................................................................................................................................72
blueSaturation ................................................................................................................................................................72
brightness.........................................................................................................................................................................72
chromaticAberrationBY...............................................................................................................................................72
chromaticAberrationRC...............................................................................................................................................72
colorNoiseReduction....................................................................................................................................................72
colorSpace........................................................................................................................................................................72
contrast .............................................................................................................................................................................72
exposure ...........................................................................................................................................................................72
greenHue..........................................................................................................................................................................72
greenSaturation .............................................................................................................................................................72
luminanceSmoothing ..................................................................................................................................................72
redHue...............................................................................................................................................................................72
redSaturation ..................................................................................................................................................................72
resolution..........................................................................................................................................................................72
saturation .........................................................................................................................................................................72
settings..............................................................................................................................................................................72
shadows ............................................................................................................................................................................72
shadowTint ......................................................................................................................................................................72
sharpness..........................................................................................................................................................................72
size ......................................................................................................................................................................................72
temperature.....................................................................................................................................................................72
tint.......................................................................................................................................................................................73
typename .........................................................................................................................................................................73
vignettingAmount ........................................................................................................................................................73
vignettingMidpoint ......................................................................................................................................................73
Adobe Photoshop
JavaScript Scripting Reference 10
whiteBalance...................................................................................................................................................................73
Channel............................................................................................................................................................................................74
Properties..................................................................................................................................................................................74
color....................................................................................................................................................................................74
histogram .........................................................................................................................................................................74
kind .....................................................................................................................................................................................74
name...................................................................................................................................................................................74
opacity ...............................................................................................................................................................................74
parent.................................................................................................................................................................................74
typename .........................................................................................................................................................................74
visible .................................................................................................................................................................................74
Methods ....................................................................................................................................................................................74
duplicate ...........................................................................................................................................................................74
merge.................................................................................................................................................................................75
remove...............................................................................................................................................................................75
Channels ..........................................................................................................................................................................................76
Properties..................................................................................................................................................................................76
length.................................................................................................................................................................................76
parent.................................................................................................................................................................................76
typename .........................................................................................................................................................................76
Methods ....................................................................................................................................................................................76
add ......................................................................................................................................................................................76
getByName ......................................................................................................................................................................76
removeAll .........................................................................................................................................................................76
CMYKColor......................................................................................................................................................................................81
Properties..................................................................................................................................................................................81
black ...................................................................................................................................................................................81
cyan.....................................................................................................................................................................................81
magenta............................................................................................................................................................................81
typename .........................................................................................................................................................................81
yellow.................................................................................................................................................................................81
ColorSampler .................................................................................................................................................................................82
Properties..................................................................................................................................................................................82
color....................................................................................................................................................................................82
position .............................................................................................................................................................................82
parent.................................................................................................................................................................................82
typename .........................................................................................................................................................................82
Methods ....................................................................................................................................................................................82
move...................................................................................................................................................................................82
remove...............................................................................................................................................................................82
ColorSamplers ...............................................................................................................................................................................83
Properties..................................................................................................................................................................................83
length.................................................................................................................................................................................83
parent.................................................................................................................................................................................83
typename .........................................................................................................................................................................83
Methods ....................................................................................................................................................................................83
add ......................................................................................................................................................................................83
removeAll .........................................................................................................................................................................83
ContactSheetOptions .................................................................................................................................................................84
Properties..................................................................................................................................................................................84
acrossFirst.........................................................................................................................................................................84
Adobe Photoshop
JavaScript Scripting Reference 11
bestFit ................................................................................................................................................................................84
caption...............................................................................................................................................................................84
columnCount ..................................................................................................................................................................84
flatten.................................................................................................................................................................................84
font......................................................................................................................................................................................84
fontSize..............................................................................................................................................................................84
height.................................................................................................................................................................................84
horizontal .........................................................................................................................................................................84
mode ..................................................................................................................................................................................84
resolution..........................................................................................................................................................................84
rowCount..........................................................................................................................................................................84
typename .........................................................................................................................................................................84
useAutoSpacing.............................................................................................................................................................84
vertical ...............................................................................................................................................................................84
width ..................................................................................................................................................................................84
CountItem .......................................................................................................................................................................................85
Properties..................................................................................................................................................................................85
position .............................................................................................................................................................................85
parent.................................................................................................................................................................................85
typename .........................................................................................................................................................................85
Methods ....................................................................................................................................................................................85
remove...............................................................................................................................................................................85
CountItems .....................................................................................................................................................................................86
Properties..................................................................................................................................................................................86
length.................................................................................................................................................................................86
parent.................................................................................................................................................................................86
typename .........................................................................................................................................................................86
Methods ....................................................................................................................................................................................86
add ......................................................................................................................................................................................86
getByName ......................................................................................................................................................................86
removeAll .........................................................................................................................................................................86
DCS1_SaveOptions......................................................................................................................................................................87
Properties..................................................................................................................................................................................87
dCS ......................................................................................................................................................................................87
embedColorProfile........................................................................................................................................................87
encoding...........................................................................................................................................................................87
halftoneScreen ...............................................................................................................................................................87
interpolation....................................................................................................................................................................87
preview..............................................................................................................................................................................87
transferFunction.............................................................................................................................................................87
typename .........................................................................................................................................................................87
vectorData........................................................................................................................................................................87
DCS2_SaveOptions......................................................................................................................................................................88
Properties..................................................................................................................................................................................88
dCS ......................................................................................................................................................................................88
embedColorProfile........................................................................................................................................................88
encoding...........................................................................................................................................................................88
halftoneScreen ...............................................................................................................................................................88
interpolation....................................................................................................................................................................88
multiFileDCS....................................................................................................................................................................88
preview..............................................................................................................................................................................88
Adobe Photoshop
JavaScript Scripting Reference 12
spotColors ........................................................................................................................................................................88
transferFunction.............................................................................................................................................................88
typename .........................................................................................................................................................................88
vectorData........................................................................................................................................................................88
DICOMOpenOptions ...................................................................................................................................................................89
Properties..................................................................................................................................................................................89
anonymize........................................................................................................................................................................89
columns.............................................................................................................................................................................89
reverse ...............................................................................................................................................................................89
rows ....................................................................................................................................................................................89
showOverlays..................................................................................................................................................................89
typename .........................................................................................................................................................................89
windowLevel ...................................................................................................................................................................89
windowWidth .................................................................................................................................................................89
Document .......................................................................................................................................................................................90
Properties..................................................................................................................................................................................90
activeChannels ...............................................................................................................................................................90
activeHistoryBrushSource ..........................................................................................................................................90
activeHistoryState .........................................................................................................................................................90
activeLayer .......................................................................................................................................................................90
artLayers............................................................................................................................................................................90
backgroundLayer...........................................................................................................................................................90
bitsPerChannel ...............................................................................................................................................................90
channels............................................................................................................................................................................90
cloudDocument .............................................................................................................................................................90
cloudWorkAreaDirectory ............................................................................................................................................90
colorProfileName...........................................................................................................................................................90
colorProfileType .............................................................................................................................................................90
colorSamplers .................................................................................................................................................................90
componentChannels....................................................................................................................................................91
countItems .......................................................................................................................................................................91
fullName............................................................................................................................................................................91
guides ................................................................................................................................................................................91
height.................................................................................................................................................................................91
histogram .........................................................................................................................................................................91
historyStates....................................................................................................................................................................91
info ......................................................................................................................................................................................91
layerComps ......................................................................................................................................................................91
layers ..................................................................................................................................................................................91
layerSets............................................................................................................................................................................91
managed...........................................................................................................................................................................91
measurementScale .......................................................................................................................................................91
mode ..................................................................................................................................................................................91
name...................................................................................................................................................................................91
parent.................................................................................................................................................................................91
path.....................................................................................................................................................................................91
pathItems .........................................................................................................................................................................91
pixelAspectRatio ............................................................................................................................................................91
printSettings....................................................................................................................................................................92
quickMaskMode.............................................................................................................................................................92
resolution..........................................................................................................................................................................92
Adobe Photoshop
JavaScript Scripting Reference 13
saved ..................................................................................................................................................................................92
selection............................................................................................................................................................................92
typename .........................................................................................................................................................................92
width ..................................................................................................................................................................................92
xmpMetadata..................................................................................................................................................................92
Methods ....................................................................................................................................................................................93
autoCount ........................................................................................................................................................................93
changeMode ...................................................................................................................................................................93
close....................................................................................................................................................................................93
convertProfile..................................................................................................................................................................93
crop.....................................................................................................................................................................................93
duplicate ...........................................................................................................................................................................93
exportDocument ...........................................................................................................................................................94
flatten.................................................................................................................................................................................94
flipCanvas .........................................................................................................................................................................94
importAnnotations .......................................................................................................................................................94
mergeVisibleLayers.......................................................................................................................................................94
paste...................................................................................................................................................................................94
print ....................................................................................................................................................................................94
printOneCopy .................................................................................................................................................................94
rasterizeAllLayers...........................................................................................................................................................94
recordMeasurements...................................................................................................................................................94
resizeCanvas ....................................................................................................................................................................94
resizeImage......................................................................................................................................................................95
revealAll.............................................................................................................................................................................95
rotateCanvas ...................................................................................................................................................................95
save.....................................................................................................................................................................................95
saveAs ................................................................................................................................................................................95
splitChannels...................................................................................................................................................................95
suspendHistory...............................................................................................................................................................95
trap......................................................................................................................................................................................95
trim......................................................................................................................................................................................96
DocumentPrintSettings .............................................................................................................................................................98
Properties..................................................................................................................................................................................98
backgroundColor...........................................................................................................................................................98
bleedWidth ......................................................................................................................................................................98
caption...............................................................................................................................................................................98
centerCropMarks ...........................................................................................................................................................98
colorBars ...........................................................................................................................................................................98
copies.................................................................................................................................................................................98
cornerCropMarks ...........................................................................................................................................................98
colorHandling .................................................................................................................................................................98
activePrinter ....................................................................................................................................................................98
flip........................................................................................................................................................................................98
hardProof..........................................................................................................................................................................98
interpolate........................................................................................................................................................................98
labels ..................................................................................................................................................................................98
mapBlack ..........................................................................................................................................................................98
negative ............................................................................................................................................................................98
renderIntent ....................................................................................................................................................................98
posX....................................................................................................................................................................................98
Adobe Photoshop
JavaScript Scripting Reference 14
posY ....................................................................................................................................................................................98
printBorder.......................................................................................................................................................................98
printerName ....................................................................................................................................................................98
printSpace ........................................................................................................................................................................98
registrationMarks...........................................................................................................................................................98
scale ....................................................................................................................................................................................99
vectorData........................................................................................................................................................................99
Methods ................................................................................................................................................................................. 100
setPagePosition........................................................................................................................................................... 100
DocumentInfo ............................................................................................................................................................................ 101
Properties............................................................................................................................................................................... 101
author ............................................................................................................................................................................. 101
authorPosition ............................................................................................................................................................. 101
caption............................................................................................................................................................................ 101
captionWriter ............................................................................................................................................................... 101
category ......................................................................................................................................................................... 101
city.................................................................................................................................................................................... 101
copyrighted .................................................................................................................................................................. 101
copyrightNotice .......................................................................................................................................................... 101
country ........................................................................................................................................................................... 101
creationDate................................................................................................................................................................. 101
credit ............................................................................................................................................................................... 101
exif.................................................................................................................................................................................... 101
headline ......................................................................................................................................................................... 101
instructions ................................................................................................................................................................... 101
jobName ........................................................................................................................................................................ 101
keywords........................................................................................................................................................................ 101
ownerUrl ........................................................................................................................................................................ 101
parent.............................................................................................................................................................................. 102
provinceState............................................................................................................................................................... 102
source.............................................................................................................................................................................. 102
supplementalCategories.......................................................................................................................................... 102
title ................................................................................................................................................................................... 102
transmissionReference ............................................................................................................................................. 102
typename ...................................................................................................................................................................... 102
urgency .......................................................................................................................................................................... 102
Documents .................................................................................................................................................................................. 104
Properties............................................................................................................................................................................... 104
length.............................................................................................................................................................................. 104
parent.............................................................................................................................................................................. 104
typename ...................................................................................................................................................................... 104
Methods ................................................................................................................................................................................. 104
add ................................................................................................................................................................................... 104
getByName ................................................................................................................................................................... 104
EPSOpenOptions ....................................................................................................................................................................... 105
Properties............................................................................................................................................................................... 105
antiAlias.......................................................................................................................................................................... 105
constrainProportions ................................................................................................................................................ 105
height.............................................................................................................................................................................. 105
mode ............................................................................................................................................................................... 105
resolution....................................................................................................................................................................... 105
Adobe Photoshop
JavaScript Scripting Reference 15
Properties............................................................................................................................................................................... 112
activeLinkColor............................................................................................................................................................ 112
backgroundColor........................................................................................................................................................ 112
bannerColor.................................................................................................................................................................. 112
linkColor......................................................................................................................................................................... 112
textColor ........................................................................................................................................................................ 112
typename ...................................................................................................................................................................... 112
visitedLinkColor........................................................................................................................................................... 112
GalleryImagesOptions ............................................................................................................................................................. 113
Properties............................................................................................................................................................................... 113
border ............................................................................................................................................................................. 113
caption............................................................................................................................................................................ 113
dimension...................................................................................................................................................................... 113
font................................................................................................................................................................................... 113
fontSize........................................................................................................................................................................... 113
imageQuality................................................................................................................................................................ 113
includeCopyright........................................................................................................................................................ 113
includeCredits.............................................................................................................................................................. 113
includeFilename.......................................................................................................................................................... 113
includeTitle ................................................................................................................................................................... 113
numericLinks ................................................................................................................................................................ 113
resizeConstraint .......................................................................................................................................................... 114
resizeImages................................................................................................................................................................. 114
typename ...................................................................................................................................................................... 114
GalleryOptions............................................................................................................................................................................ 115
Properties............................................................................................................................................................................... 115
addSizeAttributes....................................................................................................................................................... 115
bannerOptions ............................................................................................................................................................ 115
customColorOptions ................................................................................................................................................. 115
emailAddress................................................................................................................................................................ 115
imagesOptions ............................................................................................................................................................ 115
includeSubFolders ..................................................................................................................................................... 115
layoutStyle .................................................................................................................................................................... 115
preserveAllMetadata ................................................................................................................................................. 115
securityOptions ........................................................................................................................................................... 115
thumbnailOptions...................................................................................................................................................... 115
typename ...................................................................................................................................................................... 115
useShortExtension ..................................................................................................................................................... 115
useUTF8Encoding ...................................................................................................................................................... 115
GallerySecurityOptions ........................................................................................................................................................... 116
Properties............................................................................................................................................................................... 116
content ........................................................................................................................................................................... 116
font................................................................................................................................................................................... 116
fontSize........................................................................................................................................................................... 116
opacity ............................................................................................................................................................................ 116
text ................................................................................................................................................................................... 116
textColor ........................................................................................................................................................................ 116
textPosition................................................................................................................................................................... 116
textRotate...................................................................................................................................................................... 116
typename ...................................................................................................................................................................... 116
GalleryThumbnailOptions...................................................................................................................................................... 117
Adobe Photoshop
JavaScript Scripting Reference 17
Properties............................................................................................................................................................................... 117
border ............................................................................................................................................................................. 117
caption............................................................................................................................................................................ 117
columnCount ............................................................................................................................................................... 117
dimension...................................................................................................................................................................... 117
font................................................................................................................................................................................... 117
fontSize........................................................................................................................................................................... 117
includeCopyright........................................................................................................................................................ 117
includeCredits.............................................................................................................................................................. 117
includeFilename.......................................................................................................................................................... 117
includeTitle ................................................................................................................................................................... 117
rowCount....................................................................................................................................................................... 117
size ................................................................................................................................................................................... 117
typename ...................................................................................................................................................................... 117
GIFSaveOptions.......................................................................................................................................................................... 118
Properties............................................................................................................................................................................... 118
colors............................................................................................................................................................................... 118
dither............................................................................................................................................................................... 118
ditherAmount .............................................................................................................................................................. 118
forced .............................................................................................................................................................................. 118
interlaced....................................................................................................................................................................... 118
matte............................................................................................................................................................................... 118
palette............................................................................................................................................................................. 118
preserveExactColors .................................................................................................................................................. 118
transparency................................................................................................................................................................. 118
typename ...................................................................................................................................................................... 118
GrayColor...................................................................................................................................................................................... 119
Properties............................................................................................................................................................................... 119
gray .................................................................................................................................................................................. 119
typename ...................................................................................................................................................................... 119
Guide.............................................................................................................................................................................................. 120
Properties............................................................................................................................................................................... 120
direction......................................................................................................................................................................... 120
coordinate ..................................................................................................................................................................... 120
Guides............................................................................................................................................................................................ 121
Properties............................................................................................................................................................................... 121
length.............................................................................................................................................................................. 121
parent.............................................................................................................................................................................. 121
typename ...................................................................................................................................................................... 121
Methods ................................................................................................................................................................................. 121
add ................................................................................................................................................................................... 121
getByName ................................................................................................................................................................... 121
HistoryState ................................................................................................................................................................................. 122
Properties............................................................................................................................................................................... 122
name................................................................................................................................................................................ 122
parent.............................................................................................................................................................................. 122
snapshot ........................................................................................................................................................................ 122
typename ...................................................................................................................................................................... 122
HistoryStates ............................................................................................................................................................................... 123
Properties............................................................................................................................................................................... 123
length.............................................................................................................................................................................. 123
Adobe Photoshop
JavaScript Scripting Reference 18
parent.............................................................................................................................................................................. 123
typename ...................................................................................................................................................................... 123
Methods ................................................................................................................................................................................. 123
getByName ................................................................................................................................................................... 123
HSBColor....................................................................................................................................................................................... 124
Properties............................................................................................................................................................................... 124
brightness...................................................................................................................................................................... 124
hue ................................................................................................................................................................................... 124
saturation ...................................................................................................................................................................... 124
typename ...................................................................................................................................................................... 124
IndexedConversionOptions .................................................................................................................................................. 125
Properties............................................................................................................................................................................... 125
colors............................................................................................................................................................................... 125
dither............................................................................................................................................................................... 125
ditherAmount .............................................................................................................................................................. 125
forced .............................................................................................................................................................................. 125
matte............................................................................................................................................................................... 125
palette............................................................................................................................................................................. 125
preserveExactColors .................................................................................................................................................. 125
transparency................................................................................................................................................................. 125
typename ...................................................................................................................................................................... 125
JPEGSaveOptions ...................................................................................................................................................................... 126
Properties............................................................................................................................................................................... 126
embedColorProfile..................................................................................................................................................... 126
formatOptions ............................................................................................................................................................. 126
matte............................................................................................................................................................................... 126
quality ............................................................................................................................................................................. 126
scans................................................................................................................................................................................ 126
typename ...................................................................................................................................................................... 126
LabColor ....................................................................................................................................................................................... 127
Properties............................................................................................................................................................................... 127
a......................................................................................................................................................................................... 127
b ........................................................................................................................................................................................ 127
l.......................................................................................................................................................................................... 127
typename ...................................................................................................................................................................... 127
LayerComp................................................................................................................................................................................... 128
Properties............................................................................................................................................................................... 128
appearance ................................................................................................................................................................... 128
childLayerCompState................................................................................................................................................ 128
comment ....................................................................................................................................................................... 128
name................................................................................................................................................................................ 128
parent.............................................................................................................................................................................. 128
position .......................................................................................................................................................................... 128
selected .......................................................................................................................................................................... 128
typename ...................................................................................................................................................................... 128
visibility .......................................................................................................................................................................... 128
Methods ................................................................................................................................................................................. 128
apply................................................................................................................................................................................ 128
recapture ....................................................................................................................................................................... 128
remove............................................................................................................................................................................ 128
resetfromComp ........................................................................................................................................................... 128
Adobe Photoshop
JavaScript Scripting Reference 19
LayerComps................................................................................................................................................................................. 129
Properties............................................................................................................................................................................... 129
length.............................................................................................................................................................................. 129
parent.............................................................................................................................................................................. 129
typename ...................................................................................................................................................................... 129
Methods ................................................................................................................................................................................. 129
add ................................................................................................................................................................................... 129
getByName ................................................................................................................................................................... 129
removeAll ...................................................................................................................................................................... 129
Layers............................................................................................................................................................................................. 130
Properties............................................................................................................................................................................... 130
length.............................................................................................................................................................................. 130
parent.............................................................................................................................................................................. 130
typename ...................................................................................................................................................................... 130
Methods ................................................................................................................................................................................. 130
getByName ................................................................................................................................................................... 130
removeAll ...................................................................................................................................................................... 130
LayerSet ........................................................................................................................................................................................ 131
Properties............................................................................................................................................................................... 131
allLocked........................................................................................................................................................................ 131
artLayers......................................................................................................................................................................... 131
blendMode.................................................................................................................................................................... 131
bounds............................................................................................................................................................................ 131
enabledChannels........................................................................................................................................................ 131
layers ............................................................................................................................................................................... 131
layerSets......................................................................................................................................................................... 131
linkedLayers.................................................................................................................................................................. 131
name................................................................................................................................................................................ 131
opacity ............................................................................................................................................................................ 131
parent.............................................................................................................................................................................. 131
typename ...................................................................................................................................................................... 131
visible .............................................................................................................................................................................. 131
Methods ................................................................................................................................................................................. 132
duplicate ........................................................................................................................................................................ 132
link.................................................................................................................................................................................... 132
merge.............................................................................................................................................................................. 132
move................................................................................................................................................................................ 132
remove............................................................................................................................................................................ 132
resize ............................................................................................................................................................................... 132
rotate............................................................................................................................................................................... 132
translate ......................................................................................................................................................................... 132
unlink .............................................................................................................................................................................. 132
LayerSets ...................................................................................................................................................................................... 133
Properties............................................................................................................................................................................... 133
length.............................................................................................................................................................................. 133
parent.............................................................................................................................................................................. 133
typename ...................................................................................................................................................................... 133
Methods ................................................................................................................................................................................. 133
add ................................................................................................................................................................................... 133
getByName ................................................................................................................................................................... 133
removeAll ...................................................................................................................................................................... 133
Adobe Photoshop
JavaScript Scripting Reference 20
embedColorProfile..................................................................................................................................................... 156
name................................................................................................................................................................................ 156
resolution....................................................................................................................................................................... 156
resourceID ..................................................................................................................................................................... 156
typename ...................................................................................................................................................................... 156
PicturePackageOptions........................................................................................................................................................... 157
Properties............................................................................................................................................................................... 157
content ........................................................................................................................................................................... 157
flatten.............................................................................................................................................................................. 157
font................................................................................................................................................................................... 157
fontSize........................................................................................................................................................................... 157
layout .............................................................................................................................................................................. 157
mode ............................................................................................................................................................................... 157
opacity ............................................................................................................................................................................ 157
resolution....................................................................................................................................................................... 157
text ................................................................................................................................................................................... 157
textColor ........................................................................................................................................................................ 157
textPosition................................................................................................................................................................... 157
textRotate...................................................................................................................................................................... 157
typename ...................................................................................................................................................................... 157
PixarSaveOptions ...................................................................................................................................................................... 158
Properties............................................................................................................................................................................... 158
alphaChannels ............................................................................................................................................................. 158
typename ...................................................................................................................................................................... 158
PNGSaveOptions ....................................................................................................................................................................... 159
Properties............................................................................................................................................................................... 159
compression ................................................................................................................................................................. 159
interlaced....................................................................................................................................................................... 159
typename ...................................................................................................................................................................... 159
Preferences .................................................................................................................................................................................. 160
Properties............................................................................................................................................................................... 160
additionalPluginFolder............................................................................................................................................. 160
appendExtension........................................................................................................................................................ 160
askBeforeSavingLayeredTIFF.................................................................................................................................. 160
autoUpdateOpenDocuments ................................................................................................................................ 160
beepWhenDone.......................................................................................................................................................... 160
colorChannelsInColor ............................................................................................................................................... 160
colorPicker..................................................................................................................................................................... 160
columnGutter............................................................................................................................................................... 160
columnWidth ............................................................................................................................................................... 160
createFirstSnapshot................................................................................................................................................... 160
dynamicColorSliders.................................................................................................................................................. 160
editLogItems ................................................................................................................................................................ 160
exportClipboard.......................................................................................................................................................... 161
fontPreviewSize........................................................................................................................................................... 161
fullSizePreview............................................................................................................................................................. 161
gamutWarningOpacity............................................................................................................................................. 161
gridSize........................................................................................................................................................................... 161
gridStyle ......................................................................................................................................................................... 161
gridSubDivisions......................................................................................................................................................... 161
guideStyle...................................................................................................................................................................... 161
Adobe Photoshop
JavaScript Scripting Reference 24
height.............................................................................................................................................................................. 165
interleaveChannels .................................................................................................................................................... 165
retainHeader................................................................................................................................................................. 165
typename ...................................................................................................................................................................... 165
width ............................................................................................................................................................................... 165
RawSaveOptions........................................................................................................................................................................ 166
Properties............................................................................................................................................................................... 166
alphaChannels ............................................................................................................................................................. 166
spotColors ..................................................................................................................................................................... 166
typename ...................................................................................................................................................................... 166
RGBColor....................................................................................................................................................................................... 167
Properties............................................................................................................................................................................... 167
blue.................................................................................................................................................................................. 167
green ............................................................................................................................................................................... 167
hexValue ........................................................................................................................................................................ 167
red .................................................................................................................................................................................... 167
typename ...................................................................................................................................................................... 167
Selection ....................................................................................................................................................................................... 168
Properties............................................................................................................................................................................... 168
bounds............................................................................................................................................................................ 168
parent.............................................................................................................................................................................. 168
solid ................................................................................................................................................................................. 168
typename ...................................................................................................................................................................... 168
Methods ................................................................................................................................................................................. 168
clear ................................................................................................................................................................................. 168
contract .......................................................................................................................................................................... 168
copy ................................................................................................................................................................................. 168
cut..................................................................................................................................................................................... 168
deselect .......................................................................................................................................................................... 168
expand............................................................................................................................................................................ 168
feather............................................................................................................................................................................. 168
fill ...................................................................................................................................................................................... 169
grow ................................................................................................................................................................................ 169
invert ............................................................................................................................................................................... 169
load .................................................................................................................................................................................. 169
makeWorkPath ............................................................................................................................................................ 169
resize ............................................................................................................................................................................... 169
resizeBoundary............................................................................................................................................................ 169
rotate............................................................................................................................................................................... 169
rotateBoundary ........................................................................................................................................................... 169
select ............................................................................................................................................................................... 169
selectAll .......................................................................................................................................................................... 169
selectBorder.................................................................................................................................................................. 170
similar.............................................................................................................................................................................. 170
smooth ........................................................................................................................................................................... 170
store................................................................................................................................................................................. 170
stroke............................................................................................................................................................................... 170
translate ......................................................................................................................................................................... 170
translateBoundary...................................................................................................................................................... 170
SGIRGBSaveOptions ................................................................................................................................................................. 173
Properties............................................................................................................................................................................... 173
Adobe Photoshop
JavaScript Scripting Reference 26
strikeThru....................................................................................................................................................................... 186
textComposer .............................................................................................................................................................. 186
tracking........................................................................................................................................................................... 186
typename ...................................................................................................................................................................... 186
underline........................................................................................................................................................................ 186
useAutoLeading.......................................................................................................................................................... 186
verticalScale.................................................................................................................................................................. 186
warpBend ...................................................................................................................................................................... 186
warpDirection .............................................................................................................................................................. 186
warpHorizontalDistortion........................................................................................................................................ 186
warpStyle....................................................................................................................................................................... 186
warpVerticalDistortion.............................................................................................................................................. 186
width ............................................................................................................................................................................... 186
Methods ................................................................................................................................................................................. 187
convertToShape.......................................................................................................................................................... 187
createPath ..................................................................................................................................................................... 187
TiffSaveOptions.......................................................................................................................................................................... 188
Properties............................................................................................................................................................................... 188
alphaChannels ............................................................................................................................................................. 188
annotations................................................................................................................................................................... 188
byteOrder ...................................................................................................................................................................... 188
embedColorProfile..................................................................................................................................................... 188
imageCompression.................................................................................................................................................... 188
interleaveChannels .................................................................................................................................................... 188
jpegQuality ................................................................................................................................................................... 188
layerCompression....................................................................................................................................................... 188
layers ............................................................................................................................................................................... 188
saveImagePyramid..................................................................................................................................................... 188
spotColors ..................................................................................................................................................................... 188
transparency................................................................................................................................................................. 188
typename ...................................................................................................................................................................... 188
UnitValue...................................................................................................................................................................................... 189
xmpMetadata ............................................................................................................................................................................. 190
Properties............................................................................................................................................................................... 190
parent.............................................................................................................................................................................. 190
rawData .......................................................................................................................................................................... 190
typename ...................................................................................................................................................................... 190
3 JavaScript Resource.................................................................................................................191
JavaScript resource syntax..................................................................................................................................................... 191
Basic JavaScript resource example ............................................................................................................................... 192
Enable-info grammar ............................................................................................................................................................... 192
Undefined values in enable-info evaluation ............................................................................................................. 195
Using the "in" function...................................................................................................................................................... 195
Action Manager automation................................................................................................................................................. 195
Terminology dictionary .................................................................................................................................................... 195
Value type defintions .................................................................................................................................................. 196
Uniqueness rules for terminology entries.................................................................................................................. 197
Terminology definition example................................................................................................................................... 197
4 Scripting Constants .................................................................................................................199
AdjustmentReference ............................................................................................................................................... 199
Adobe Photoshop
JavaScript Scripting Reference 29
AnchorPosition............................................................................................................................................................ 199
AntiAlias ......................................................................................................................................................................... 199
AutoKernType.............................................................................................................................................................. 199
BatchDestinationType .............................................................................................................................................. 199
BitmapConversionType............................................................................................................................................ 200
BitmapHalfToneType ................................................................................................................................................ 200
BitsPerChannelType................................................................................................................................................... 200
BlendMode.................................................................................................................................................................... 200
BMPDepthType ........................................................................................................................................................... 200
ByteOrder ...................................................................................................................................................................... 201
CameraRAWSettingsType........................................................................................................................................ 201
CameraRAWSize.......................................................................................................................................................... 201
ChangeMode................................................................................................................................................................ 201
ChannelType ................................................................................................................................................................ 201
ColorBlendMode......................................................................................................................................................... 202
ColorModel ................................................................................................................................................................... 202
ColorPicker.................................................................................................................................................................... 202
ColorProfileType ......................................................................................................................................................... 202
ColorReductionType.................................................................................................................................................. 202
ColorSpaceType .......................................................................................................................................................... 202
CopyrightedType........................................................................................................................................................ 202
CreateFields .................................................................................................................................................................. 203
CropToType .................................................................................................................................................................. 203
DCSType......................................................................................................................................................................... 203
DepthMapSource ....................................................................................................................................................... 203
DescValueType ............................................................................................................................................................ 203
DialogModes ................................................................................................................................................................ 203
Direction ........................................................................................................................................................................ 203
DisplacementMapType ............................................................................................................................................ 204
Dither .............................................................................................................................................................................. 204
DocPositionStyle......................................................................................................................................................... 204
DocumentFill................................................................................................................................................................ 204
DocumentMode.......................................................................................................................................................... 204
EditLogItemsType....................................................................................................................................................... 204
ElementPlacement..................................................................................................................................................... 204
EliminateFields ............................................................................................................................................................ 204
ExportType.................................................................................................................................................................... 204
Extension ....................................................................................................................................................................... 204
FileNamingType .......................................................................................................................................................... 205
FontPreviewType........................................................................................................................................................ 205
FontSize.......................................................................................................................................................................... 205
ForcedColors ................................................................................................................................................................ 205
FormatOptions ............................................................................................................................................................ 205
GalleryConstrainType................................................................................................................................................ 205
GalleryFontType.......................................................................................................................................................... 206
GallerySecurityTextColorType ............................................................................................................................... 206
GallerySecurityTextPositionType.......................................................................................................................... 206
GallerySecurityTextRotateType ............................................................................................................................. 206
GallerySecurityType................................................................................................................................................... 206
GalleryThumbSizeType............................................................................................................................................. 206
Geometry....................................................................................................................................................................... 206
Adobe Photoshop
JavaScript Scripting Reference 30
This reference describes the objects and methods in the Adobe® Photoshop® JavaScriptTM type library. A
companion document, Photoshop 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 uses ExtendScript, Adobe’s extended implementation of JavaScript. See JavaScript
support in Adobe Photoshop for additional information.
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. For Windows, using
the .jsx extension is preferrable, since it interprets the script with the ExtendScript engine.
All of the Adobe Creative Cloud applications, including Adobe Photoshop, 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 File object,
the Folder object, and the UnitValue object. For that reason, using the .jsx extension for your script
files is preferable.
For details of these and additional features, see the JavaScript Tools Guide. This document is installed with
Creative Cloud applications at these locations:
? In Windows:
C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit CC\SDK
32
Adobe Photoshop
JavaScript Scripting Reference Introduction 33
? In Mac OS:
Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CC/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 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 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/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 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.
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 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 CC\Adobe Photoshop
? On Mac OS, the startup folder for user-defined scripts is:
~/Library/Application Support/Adobe/Startup Scripts CC/Adobe Photoshop
If a script is meant to be executed only by Adobe Photoshop, it must include code such as the following:
if( BridgeTalk.appName == "photoshop" ) {
//continue executing script
}
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.
For example, the collection of all open documents is contained in the top-level Application object. You
can access this through the global variable app, or simply reference its properties directly at the top level:
app.documents[0] // get the first loaded documented
documents[0] // this is the same
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 ArtLayer object in a set:
var myLayer = activeDocument.layerSets[0].artLayers[0];
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);
2 JavaScript Object Reference
The Photoshop objects (the JavaScript type library for Adobe® Photoshop®) 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.
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.
35
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 36
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
JavaScript Scripting Reference JavaScript Object Reference 37
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 ‘Selection sample script’ on page 170.
Many configuration files use serialized action descriptors to represent their data. It is used, for example, to
encapsulate playback options in Application.playbackParameters, and is returned by
Application.getCustomOptions().
Properties
Property Value type What it is
count number Read-only. The number of keys contained in the descriptor.
typename string Read-only. The class name of the referenced
actionDescriptor object.
Methods
Method Parameter type Returns What it does
clear Clears the descriptor.
()
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(), to append new elements, and can clear the entire
list using clear(), but cannot otherwise modify the list.
Note: The ActionList object is part of the Action Manager functionality. For details on using the Action
Manager, see the Photoshop Scripting Guide.
Properties
Property Value type What it is
count number Read-only. The number of commands that comprise the
action.
typename string Read-only. The class name of the referenced
ActionList object.
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.
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 string Read-only. The class name of the referenced Action
object.
Methods
Method Parameter type Returns What it does
getContainer 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.
getDesiredClass number Gets a number representing the
() class of the object.
getEnumeratedType number Gets the enumeration type.
()
Application
The Adobe Adobe Photoshop 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 app. For example:
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 Application object altogether. For example:
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 Document Read-write. The frontmost document.
Setting this property is equivalent to clicking an
open document in the Adobe Photoshop
application to bring it to the front of the screen.
Methods
Method Parameter type Returns What it does
batch string Runs the batch automation routine
(inputFiles, array of File (similar to the File > Automate >
action, string
string Batch command).
from
[, options]) BatchOptions The inputFiles parameter specifies
the sources for the files to be
manipulated by the batch command.
beep Causes a "beep" sound.
()
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.
// 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?")
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
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")
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/")
// get all the files found in this folder that are Adobe Photoshop (.psd
format)
var inputFiles = inputFolder.getFiles("*.psd")
}
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 55
ArtLayer
An object within a document that contains the visual elements of the image (equivalent to a layer in the
Adobe Photoshop application).
Access an art layer in a document through the Document.artLayers collection. You can access a layer by
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 boolean Read-write. True to completely lock the contents and
settings of this layer.
blendMode BlendMode Read-write. The blending mode.
bounds array of Read-only. An array of coordinates that describes the
UnitValue
bounding rectangle of the layer.
boundsNoEffects array of Read-only. An array of coordinates that describes the
UnitValue
bounding rectangle of the layer not including effects.
fillOpacity number [0.0..100] Read-write. The interior opacity of the layer, a
percentage value.
filterMaskDensity double Read-write. The density of the filter mask (between
0.0 and 250.0)
filterMaskFeather double Read-write. The feather of the filter mask (between 0.0
and 250.0)
grouped boolean Read-write. True if this layer is grouped with the layer
beneath it.
isBackgroundLayer boolean 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.
kind LayerKind 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 isBackgroundLayer
to true.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 56
Methods
Method Parameter type Returns What it does
adjustBrightnessContrast Adjusts the brightness in the
(brightness, number range [-100..100] and contrast
contrast) number
[-100..100].
adjustColorBalance Adjusts the color balance of the
([shadows] array of number layer’s component channels. For
[, midtones] array of number
array of number shadows, midtones, and
[, highlights]
[, preserveLuminosity] boolean 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.
See Document.mode.
adjustCurves Adjusts the tonal range of the
(curveShape) array of array of number 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.
adjustLevels Adjusts the levels of the
(inputRangeStart, number [0..253] selected channels
inputRangeEnd, number [(start + 2)..255]
inputRangeGamma, number [0.10..9.99]
outputRangeStart, number [0..253]
outputRangeEnd) number [(start + 2)..255]
ArtLayer.jsx
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 65
// Use the path to the application and append the samples folder
var samplesFolder = Folder(app.path + "/Samples/")
// use the document name for the layer name in the merged document
var docName = app.activeDocument.name
}
}
ArtLayers
The collection of ArtLayer objects in a document or layer set.
Properties
Property Value type What it is
length number Read-only. The number of elements in the artLayers
collection.
parent Document Read-only. The object's container.
typename string Read-only. The class name of the referenced
artLayers object.
Methods
Method Parameter type Returns What it does
add ArtLayer Creates a new art layer in the
() document and adds the new object to
this collection.
getByName ArtLayer Get the first element in the artLayers
(name) string collection with the provided name.
removeAll Removes all elements from the
() artLayers collection.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 68
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 BatchDestinationType Read-write. The type of destination for the
processed files (default:
BatchDestinationType.NODESTINATION).
unixCompatible boolean Read-write. True to make the final file name Unix
compatible (default: true).
Valid only when destination =
BatchDestinationType.FOLDER.
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.desaturate() method.
Properties
Property Value type What it is
angle number [-180..180] Read-write. The angle (in degrees) at which to
orient individual dots. See shape.
Valid only when method =
BitmapConversionType.HALFTONESCREEN.
frequency number [1.0..999.99] Read-write. The number of printer dots (per inch) to
use.
Valid only when method =
BitmapConversionType.HALFTONESCREEN.
BMPSaveOptions
Options for saving a document in BMP format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels.
depth BMPDepthType Read-write. The number of bits per channel.
flipRowOrder boolean Read-write. True to write the image from top
to bottom (default: false).
Available only when osType =
OperatingSystem.WINDOWS.
CameraRAWOpenOptions
Options for opening a document in Camera RAW format using the Application.open() method.
Properties
Property Value type What it is
bitsPerChannel BitsPerChannelType Read-write. The number of bits per channel.
blueHue number [-100..100] Read-write. The blue hue of the shot.
blueSaturation number [-100..100] Read-write. The blue saturation of the shot.
brightness number [0..150] Read-write. The brightness of the shot.
chromaticAberrationBY number [-100..100] Read-write. The chromatic aberration B/Y of the
shot.
chromaticAberrationRC number [-100..100] Read-write. The chromatic aberration R/C of the
shot
colorNoiseReduction number [0..100] Read-write. The color noise reduction of the
shot.
colorSpace ColorSpaceType Read-write. The colorspace for the image.
contrast number [-50..100] Read-write. The contrast of the shot.
exposure number [-4.0..4.0] Read-write. The exposure of the shot.
greenHue number [-100..100] Read-write. The green hue of the shot.
greenSaturation number [-100..100] Read-write. The green saturation of the shot.
luminanceSmoothing number [0..100] Read-write. The luminance smoothing of the
shot.
redHue number [-100..100] Read-write. The red hue of the shot.
redSaturation number [-100..100] Read-write. The red saturation of the shot.
resolution number [1..999] Read-write. The resolution of the document in
pixels per inch.
saturation number [-100..100] Read-write. The saturation of the shot.
settings CameraRAWSettingsType Read-write. The global settings for all Camera
RAW options. Default:
CameraRAWSettingsType.CAMERA.
Channel
Information about a color element in the image.
Access through the Document.channels collection. You can access an individual channel object in this list
by index or by name. For example, this accesses a channel object in the active document by name and
assigns an opacity value:
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 SolidColor Read-write. The color of the channel.
Not valid when kind = ChannelType.COMPONENT.
histogram array of number 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 ChannelType Read-write. The type of the channel.
name string Read-write. The name of the channel.
opacity number [0..100] Read-write. The opacity to use for alpha channels or the
solidity to use for spot channels.
Valid only when kind = ChannelType.MASKEDAREA or
SELECTEDAREA.
Methods
Method Parameter type Returns What it does
duplicate Channel Duplicates the channel.
([targetDocument]) Document
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 75
Channels
The collection of Channel objects in a document.
Properties
Property Value type What it is
length number Read-only. The number of elements in the channels
collection.
parent Document Read-only. The containing document.
typename string Read-only. The class name of the referenced channels
object.
Methods
Method Parameter type Returns What it does
add Channel Creates a new channel object and
() adds it to this collection.
getByName Channel Get the first element in the channels
(name) string collection with the provided name.
removeAll Removes all alpha channel objects
() from the channels collection.
Note: This script contains a switch construction that uses a break statement. The break statement
requires an ending semicolon (;), as in the following sample:
break;
Histogram.jsx
case DocumentMode.BITMAP:
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 77
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;
}
// channel indexer
var channelIndex = 0
// 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
JavaScript Scripting Reference JavaScript Object Reference 80
// I need an extra "0" for this line item to keep everything in line
if (histogramIndex < 100)
inOutFile.write("0")
inOutFile.write("\n")
}
inOutFile.write("\n")
}
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 81
CMYKColor
Defines a CMYK color, used in the SolidColor object.
Properties
Property Value type What it is
black number [0.0..100.00] Read-write. The black color value (as percent).
cyan number [0.0..100.00] Read-write. The cyan color value (as percent).
magenta number [0.0..100.00] Read-write. The magenta color value (as percent).
typename string Read-only. The class name of the referenced CMYKColor
object.
yellow number [0.0..100.00] Read-write. The yellow color value (as percent).
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 82
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 help on the Color
SamplerTool.
Properties
Property Value type What it is
color SolidColor Read-only. The color of the color sampler.
position array of Read-only. The position of the color sampler in the
UnitValue
document. The array (x,y) represents the horizontal and
vertical location of the count item.
parent Document Read-only. The containing document.
typename string Read-only. The class name of the referenced ColorSampler
object.
Methods
Method Parameter type Returns What it does
move Moves the color sampler to a new location
(position) array of in the document.
UnitValue
The position parameter (x,y) represents
the new horizontal and vertical locations
of the moved color sampler.
remove Deletes the ColorSampler object.
()
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 83
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 number Read-only. The number of elements in the
ColorSamplers collection.
Methods
Method Parameter type Returns What it does
add ColorSampler Creates a new color sampler object
(position) array of UnitValue and adds it to this collection.
The position parameter (x,y)
represents the new horizontal and
vertical locations of the moved color
sampler.
removeAll Removes all ColorSampler objects
() from the ColorSamplers collection.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 84
ContactSheetOptions
Options for creating a contact sheet with the Application.makeContactSheet() method.
Properties
Property Value type What it is
acrossFirst boolean Read-write. True to place the images horizontally
(left to right, then top to bottom) first (default: true).
bestFit boolean Read-write. True to rotate images for the best fit
(default: false).
caption boolean Read-write. True to use the filename as a caption for
the image (default: true).
columnCount number[1..100] Read-write. The number of columns to include
(default: 5).
flatten boolean Read-write. True to flatten all layers in the final
document (default: true).
font GalleryFontType Read-write. The font used for the caption (default:
GalleryFontType.ARIAL).
fontSize number Read-write. The font size to use for the caption
(default: 12).
height number [0..29000] Read-write. The height (in pixels) of the resulting
document (default: 720).
horizontal number Read-write. The horizontal spacing (in pixels)
between images (default: 1).
mode NewDocumentMode Read-write. The document color mode (default:
NewDocumentMode.RGB).
vertical number [0..29000] Read-write. The vertical spacing (in pixels) between
images (default: 1).
Valid only when useAutoSpacing = false.
width number [100..29000] Read-write. The width (in pixels) of the resulting
document (default: 576).
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 85
CountItem
A counted item in a document. Access through the Document.countItems collection. See the
Document.autoCount() method.
For additional information about count items, see Adobe Photoshop help on the Count Tool.
Properties
Property Value type What it is
position array of Read-only. The position of the count item in the document.
UnitValue
Methods
Method Parameter type Returns What it does
remove Deletes the CountItem object.
()
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 86
CountItems
The collection of CountItem objects in the document.
Properties
Property Value type What it is
length number Read-only. The number of elements in the CountItems
collection.
parent Document Read-only. The containing document.
typename string Read-only. The class name of the referenced CountItems
object.
Methods
Method Parameter type Returns What it does
add CountItem Creates a new count item object and
(position) array of UnitValue adds it to this collection.
Parameter position (x,y) represents
the horizontal and vertical positions,
respectively, of the CountItem object.
getByName CountItem Get the first element in the
(name) string CountItems collection with the
provided name.
removeAll Removes all CountItem objects from
() the CountItems collection.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 87
DCS1_SaveOptions
Options for saving a CMYK document in DCS1 format using the Document.saveAs() method.
Properties
Property Value type What it is
dCS DCSType Read-write. (default: DCSType.COLORCOMPOSITE).
embedColorProfile boolean Read-write. True to embed the color profile in the
document
encoding SaveEncoding Read-write. The type of encoding to use for document
(default: SaveEncoding.BINARY).
halftoneScreen boolean Read-write. True to include halftone screen (default:
false).
DCS2_SaveOptions
Options for saving a CMYK document in DCS2 format using the Document.saveAs() method.
Properties
Property Value type What it is
dCS DCSType Read-write. The type of composite file to create
(default: DCSType.NOCOMPOSITE).
embedColorProfile boolean Read-write. True to embed the color profile in the
document.
encoding SaveEncoding Read-write. The type of encoding to use (default:
SaveEncoding.BINARY).
DICOMOpenOptions
Options for opening a document in DICOM format using the Application.open() method.
Properties
Property Value type What it is
anonymize boolean Read-write. True to make the patient
information anonymous.
columns number Read-write. Number of columns in n-up
configuration.
reverse boolean Read-write. True to reverse (invert) the image.
rows number Read-write. The number of rows in n-up
configuration.
showOverlays boolean Read-write. True to show overlays.
typename string Read-only. The class name of the referenced
DICOMOpenOptions object.
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 collection. You can access individual documents in the list by index, or use
Documents.getByName() to retrieve them by name.
? Create documents programmatically using the Documents.add() method.
See Document sample script and the Documents collection object for examples.
Properties
Property Value type What it is
activeChannels array of Channel Read-write. The selected channels.
activeHistoryBrushSource Guide Read-write. The history state to use with the
history brush.
activeHistoryState Guide Read-write. The selected HistoryState object.
activeLayer ArtLayer or Read-write. The selected layer.
LayerSet
Methods
Method Parameter type Returns What it does
autoCount Counts the number of objects in a
(channel, Channel document. Available in the Extended
threshold) number
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 Help
changeMode Changes the color profile of the
(destinationMode ChangeMode document.
[, options]) BitmapConversionOptions
or
IndexedConversionOptions
Document.jsx
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// 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"))
// 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
app.activeDocument = mergedDoc
mergedDoc.selection.select(selRegion)
DocumentPrintSettings
The print settings for a document.
Properties
Property Value type What it is
backgroundColor SolidColor Read-write. Background color of page.
bleedWidth UnitValue Read-write. Bleed width
caption boolean Read-write. Print the caption found in FileInfo.
centerCropMarks boolean Read-write. Print center crop marks.
colorBars boolean Read-write. Print color calibration bars.
copies number Read-write. Number of copies to print.
cornerCropMarks boolean Read-write. Print corner crop marks.
colorHandling PrintColorHandling Read-only. Color handling.
activePrinter string Read-write. The currently active printer.
flip boolean Read-write. Flip the image horizontally.
hardProof boolean Read-write. Print a hard proof.
interpolate boolean Read-write.
labels boolean Read-write. Prints the document title.
mapBlack boolean Read-write. Map blacks.
negative boolean Read-write. Invert the image colors.
renderIntent Intent Read-write. Color conversion intent when print
space is different from the source space.
posX UnitValue Read-only. The x position of the image on
page.
posY UnitValue Read-only. The y position of the image on
page.
printBorder UnitValue Read-write. The width of the print border.
printerName string Read-write. Name of the printer.
printSpace string 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)
registrationMarks boolean Read-write. Print registration marks.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 99
Methods
Method Parameter type Returns What it does
setPagePosition Set the position of the image on the page.
(docPosition, DocPositionStyle
posX, UnitValue
posY, UnitValue
scale) number
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 101
DocumentInfo
Metadata about a document object.
Access through the Document.info property. For example, the following sets the author, caption, and
copyrighted properties:
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
These values can be set interactively by choosing File > File Info.
Properties
Property Value type What it is
author string Read-write.
authorPosition string Read-write.
caption string Read-write.
captionWriter string Read-write.
category string Read-write.
city string Read-write.
copyrighted CopyrightedType Read-write. The copyrighted status.
copyrightNotice string Read-write.
country string Read-write.
creationDate string Read-write.
credit string Read-write.
exif array of array [tag data] 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"].
DocumentInfo.jsx
Documents
The collection of open Document objects.
Access this list through the Application.documents collection property, which is available through the app
global variable, or directly at the top level. For example, the following adds a new document to the
collection:
app.documents.add(800, 500, 72, "myDocument", NewDocumentMode.RGB)
—or—
documents.add(800, 500, 72, "myDocument", NewDocumentMode.RGB)
Properties
Property Value type What it is
length number Read-only. The number of elements in the documents
collection.
parent Application Read-only. The containing application.
typename string Read-only. The class name of the referenced documents
object.
Methods
Method Parameter type Returns What it does
add Document Creates a new document object and
([width] UnitValue adds it to this collection.
[, height] UnitValue
[, resolution] number pixelAspectRatio: Default is 1.0, a
[, name] string square aspect ratio.
[, mode] NewDocumentMode
[, initialFill] DocumentFill bitsPerChannelType: Default is
[,pixelAspectRatio] number [0.1..10.00] BitsPerChannelType.EIGHT.
[, bitsPerChannel] BitsPerChannelType
string
[,colorProfileName])
EPSOpenOptions
Options for opening a document in EPS format using the Application.open() method.
Properties
Property Value type What it is
antiAlias boolean Read-write. True to use antialias.
constrainProportions boolean Read-write. True to constrain the proportions of
the image.
height UnitValue Read-write. The height of the image (unit
value).
mode OpenDocumentMode Read-write. The color profile to use as the
document mode.
resolution number Read-write. The resolution of the document in
pixels per inch.
typename string Read-only. The class name of the referenced
EPSOpenOptions object.
EPSSaveOptions
Options for saving a document in EPS format using the Document.saveAs() method.
Properties
Property Value type What it is
embedColorProfile boolean Read-write. True to embed the color profile in this
document.
encoding SaveEncoding Read-write. The type of encoding to use (default:
SaveEncoding.BINARY).
ExportOptionsIllustrator
Options for exporting PathItem objects to an Adobe Illustrator® file using using the
Document.exportDocument() method. These options are the options that you can provide when you
choose File > Export > Paths To Illustrator.
Properties
Property Value type What it is
path IllustratorPathType Read-write. The type of path to export
(default:
IllustratorPathType.DOCUMENTBOUNDS).
ExportOptionsSaveForWeb
Options for optimizing a document for the web or devices using the Document.exportDocument()
method. These are the options that you can provide when you choose File > Save For Web and Devices.
Properties
Property Value type What it is
blur number Read-write. Applies blur to the image to reduce
artifacts (default: 0.0).
colorReduction ColorReductionType Read-write. The color reduction algorithm (default:
ColorReductionType.SELECTIVE).
File
Folder
ExtendScript defines the JavaScript classes File and Folder to encapsulate file-system references in a
platform-independent manner; see ‘JavaScript support in Adobe Photoshop’ on page 32. For references
details of these classes, see the JavaScript Tools Guide.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 111
GalleryBannerOptions
Options for the bannerOptions property of the GalleryOptions object.
Tip: You can preserve default values for many of these properties by setting the GalleryOptions property
preserveAllMetadata to true; this is the same as choosing File > Automate > Web Photo Gallery, and
then choosing Preserve all metadata in the Options area of the Web Photo Gallery dialog.
Properties
Property Value type What it is
contactInfo string Read-write. The web photo gallery
contact info.
date string Read-write. The web photo gallery date
(default: current date).
font GalleryFontType Read-write. The font setting for the
banner text (default:
GalleryFontType.ARIAL).
fontSize number [1..7] Read-write. The font size for the banner
text (default: 3).
photographer string Read-write. The web photo gallery
photographer.
siteName string Read-write. The web photo gallery site
name (default:
Adobe Web Photo Gallery).
GalleryCustomColorOptions
Options for the customColorOptions property of the GalleryOptions object.
Tip: You can preserve default values for many of these properties by setting the GalleryOptions property
preserveAllMetadata to true; this is the same as choosing File > Automate > Web Photo Gallery, and
then choosing Preserve all metadata in the Options area of the Web Photo Gallery dialog.
Properties
Property Value type What it is
activeLinkColor RGBColor Read-write. The color to use to indicate
an active link.
backgroundColor RGBColor Read-write. The background color.
bannerColor RGBColor Read-write. The banner color.
linkColor RGBColor Read-write. The color to use to indicate a
link.
textColor RGBColor Read-write. The text color.
typename string Read-only. The class name of the
referenced
galleryCustomColorOptions object.
GalleryImagesOptions
Options for the imagesOptions property of the GalleryOptions object.
Tip: You can preserve default values for many of these properties by setting the GalleryOptions property
preserveAllMetadata to true; this is the same as choosing File > Automate > Web Photo Gallery, and
then choosing Preserve all metadata in the Options area of the Web Photo Gallery dialog.
Properties
Property Value type What it is
border number [0..99] Read-write. The size (in pixels) of the border
that separates images (default: 0).
caption boolean Read-write. True to generate image captions
(default: false).
dimension number Read-write. The resized image dimensions in
pixels (default: 350).
Valid only when resizeImages = true.
font GalleryFontType Read-write. The font to use for image
captions (default: GalleryFontType.ARIAL).
fontSize number [1..7] Read-write. The font size for image captions
(default: 3).
Valid only when caption = true.
imageQuality number [0..12] Read-write. The quality setting for a JPEG
image (default: 5).
includeCopyright boolean Read-write. True to include copyright
information in captions (default: false).
Valid only when caption = true.
includeCredits boolean Read-write. True to include the credits in
image captions (default: false).
Valid only when caption = true.
includeFilename boolean Read-write. True to include the file name in
image captions (default: true).
Valid only when caption = true.
includeTitle boolean Read-write. True to include the title in image
captions (default: false).
Valid only when caption = true.
numericLinks boolean Read-write. True to add numeric links
(default: true).
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 114
GalleryOptions
Options for a Web photo gallery, created with Application.makePhotoGallery().
Tip: You can preserve default values for many of these properties by choosing File > Automate > Web
Photo Gallery, and then choosing Preserve all metadata in the Options area of the Web Photo
Gallery dialog.
Properties
Property Value type What it is
addSizeAttributes boolean Read-write. True to add width and
height attributes for images (default:
true).
GallerySecurityOptions
Options for the securityOptions property of the GalleryOptions object.
Tip: You can preserve default values for many of these properties by setting the GalleryOptions property
preserveAllMetadata to true; this is the same as choosing File > Automate > Web Photo Gallery, and
then choosing Preserve all metadata in the Options area of the Web Photo Gallery dialog.
Properties
Property Value type What it is
content GallerySecurityType Read-write. The web photo gallery
security content (default:
GallerySecurityType.NONE).
GalleryThumbnailOptions
Options for the thumbnailOptions property of the GalleryOptions object.
Tip: You can preserve default values for many of these properties by setting the GalleryOptions property
preserveAllMetadata to true; this is the same as choosing File > Automate > Web Photo Gallery, and
then choosing Preserve all metadata in the Options area of the Web Photo Gallery dialog.
Properties
Property Value type What it is
border number [0..99] Read-write. The amount of border pixels you
want around your thumbnail images (default:
0).
GIFSaveOptions
Options for saving a document in GIF format using the Document.saveAs() method.
Properties
Property Value type What it is
colors number Read-write. The number of palette colors.
Valid only when palette =
Palette.LOCALADAPTIVE, LOCALPERCEPTUAL,
LOCALSELECTIVE, MACOSPALETTE, UNIFORM,
WEBPALETTE; or WINDOWSPALETTE .
GrayColor
Defines a gray color, used in the SolidColor object.
Properties
Property Value type What it is
gray number [0.0..100.0] Read-write. The gray value (default: 0.0).
Guide
Properties
Property Value type What it is
direction Direction Read-write. Indicates whether the guide is
vertical or horizontal.
coordinate UnitValue Read-write. Location of the guide from origin
of image.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 121
Guides
The collection of open Guide objects.
Access this list through the Document.guides collection property, which is available through the
activeDocument object. For example, the following adds a new guide to the collection:
activeDocument.guides.add (Direction.HORIZONTAL,UnitValue(20,20))
Properties
Property Value type What it is
length number Read-only. The number of elements in the guides
collection.
parent Document Read-only. The containing document.
typename string Read-only. The class name of the referenced guides
object.
Methods
Method Parameter type Returns What it does
add Guide Creates a new guide object and adds
(direction Direction it to this collection.
, coordinate) UnitValue
HistoryState
A version of the document stored automatically (and added to the HistoryStates collection), which
preserves the document’s state, each time the document is changed.
Access through Document.historyStates collection. You can access a state in the list by name. For example,
this assigns a property value in the state object named "AddLayerMask":
var stateRef = app.activeDocument.historyState.getByName("AddLayerMask");
stateRef.snapshot = true;
Properties
Property Value type What it is
name string Read-only. The HistoryState object's name.
parent Document Read-only. The containing document.
snapshot boolean Read-only. True if the history state is a snapshot.
typename string Read-only. The class name of the referenced HistoryState
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 123
HistoryStates
The collection of Guide objects in the document.
Access through Document.historyStates collection property. For example, this accesses one of the states in
the collection by index:
myState = app.activeDocument.historyStates[7];
Properties
Property Value type What it is
length number Read-only. The number of elements in the HistoryStates
collection.
parent Document Read-only. The containing document.
typename string Read-only. The class name of the referenced
HistoryStates object.
Methods
Method Parameter type Returns What it does
getByName Guide Get the first element in the
(name) string HistoryStates collection with the
provided name.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 124
HSBColor
Defines an HSB color, used in the SolidColor object.
Properties
Property Value type What it is
brightness number[0.0..100.0] Read-write. The brightness value.
hue number [0.0..360.0] Read-write. The hue value.
IndexedConversionOptions
Options for converting an RGB image to an indexed color model using Document.changeMode().
Properties
Property Value type What it is
colors number Read-write. The number of palette colors.
Valid only when palette =
Palette.LOCALADAPTIVE, LOCALPERCEPTUAL,
LOCALSELECTIVE, MACOSPALETTE, UNIFORM,
WEBPALETTE, or WINDOWSPALETTE.
JPEGSaveOptions
Options for saving a document in JPEG format using the Document.saveAs() method.
Properties
Property Value type What it is
embedColorProfile boolean Read-write. True to embed the color profile in the
document.
formatOptions FormatOptions Read-write.The download format to use (default:
FormatOptions.STANDARDBASELINE).
LabColor
Defines an LAB color, used in the SolidColor object.
Properties
Property Value type What it is
a number [-128.0..127.0] Read-write. The a-value.
b number [-128.0..127.0] Read-write. The b-value.
l number [0.0..100.0] Read-write. The L-value.
typename string Read-only. The class name of the referenced
LabColor object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 128
LayerComp
A snapshot of a state of the layers in a document, which can be used to view different page layouts or
compositions.
Access through Document.layerComps collection. You can access a layer comp by its name. For example,
this sets the comment property value for a LayerComp object named myLayerComp:
var layercompRef = app.activeDocument.layerComps.getByName("myLayerComp");
layercompRef.comment = "View from shoreline";
Properties
Property Value type What it is
appearance boolean Read-write. True to use layer appearance (layer styles)
settings.
childLayerCompState boolean Read-write. True to track child Smart Objects layer comp.
comment string Read-write. A description of the layer comp.
name string Read-write. The name of the layer comp.
parent Document Read-write. The containing document.
position boolean Read-write. True to use layer position.
selected boolean Read-only. True if the layer comp is currently selected.
typename string Read-only. The class name of the referenced layerComp
object.
visibility boolean Read-write. True to use layer visibility settings.
Methods
Method Parameter type Returns What it does
apply Applies the layer comp to the document.
()
LayerComps
The collection of LayerComp objects in the document.
Properties
Property Value type What it is
length number Read-only. The number of elements in the layerComps
collection.
parent Document Read-only. The containing document.
typename string Read-only. The class name of the referenced
layerComps object.
Methods
Method Parameter type Returns What it does
add LayerComp Creates a new layer composition
(name, string object and adds it to this collection.
comment, string
appearance, boolean
position, boolean
visibility, boolean
childLayerCompState) boolean
Layers
The collection of layer objects, including ArtLayer and LayerSet objects, in the document. Access through
Document.layers, or the LayerSet.layers collections properties.
For example, this uses the length property to count the number of layer objects in the active document,
then displays the number on the screen:
var layerNum = app.activeDocument.layers.length
alert(layerNum)
Properties
Property Value type What it is
length number Read-only. The number of elements in the layers
collection.
parent Document or Read-only. The containing document or layer set.
LayerSet
typename string Read-only. The class name of the referenced layers object.
Methods
Method Parameter type Returns What it does
getByName Layer Gets the first element in the layers
(name) string collection with the provided name.
removeAll Removes all layers from the collection.
()
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 131
LayerSet
A group of layer objects, which can include ArtLayer objects and other (nested) LayerSet objects. A single
command can manipulate all layers in the set.
Access top-level layers sets in a document through the Document.layerSets collection. You can access a
layer set by name. For example, the following sets the allLocked value for "myLayerSet":
var layerSetRef = app.activeDocument.layerSets.getByName("myLayerSet");
layerSetRef.allLocked = true
Access nested layer sets through the LayerSet.layerSets collection in the parent set. For example:
app.activeDocument.layerSets[0].layerSets[0];
Properties
Property Value type What it is
allLocked boolean Read-write. True if the contents in the layers in this set
are not editable.
artLayers ArtLayers Read-only. The art layers in this layer set.
blendMode BlendMode Read-write. The blend mode to use for the layer set.
bounds array of UnitValue Read-only. The bounding rectangle of the layer set.
enabledChannels array of Channel Read-write. The channels enabled for the layer set; must
be a list of component channels. See Channel.kind.
layers Layers Read-only. The layers in this layer set.
layerSets LayerSets Read-only. Nested layer sets contained within this layer
set.
linkedLayers array of ArtLayer Read-only. The layers linked to this layerSet object.
and/or LayerSet
Methods
Method Parameter type Returns What it does
duplicate LayerSet Creates a duplicate of the object.
([relativeObject] ArtLayer or
LayerSet
ElementPlacement
[, insertionLocation])
LayerSets
The collection of LayerSet objects in the document.
Access the top-level layer sets in a document through the Document.layerSets collection property. For
example:
var layerSetRef = app.activeDocument.layerSets.add()
Access the nested layer sets through the LayerSet.layerSets collection property in the parent set. For
example:
var layerSetRef = app.activeDocument.layerSets.getByName("myParentSet");
var childSet = layerSetRef.layerSets.getByName("myChildSet");
Properties
Property Value type What it is
length number Read-only. The number of elements in the LayerSets
collection.
parent Document or Read-only. The containing document or layer set.
LayerSet
Methods
Method Parameter type Returns What it does
add LayerSet Creates a new layer set object and adds it to
() the collection.
getByName LayerSet Gets the first element in the collection with
(name) string the provided name.
removeAll Removes all member layer sets, and any
() layers or layer sets they contain, from the
document.
Note: This script uses the ExtendScript $ debugging object. For further details, see the JavaScript Tools
Guide.
LayerSets.jsx
$.level = 1
app.activeDocument.close()
}
// Rearrange the layer sets with the first one on top, second next, etc.
myLayerSets[1][0].moveAfter(myLayerSets[0][0])
myLayerSets[2][0].moveAfter(myLayerSets[1][0])
MeasurementLog
The measurement log for the application. Access through the Application.measurementLog property.
Methods
Method Parameter type Returns What it does
exportMeasurements Export measurement to a file.
([file] File
[, range]) MeasurementRange
[, dataPoints]) array of string
MeasurementScale
The measurement scale for the document. Access through the Document.measurementScale property.
For example:
app.activeDocument.measurementScale.pixelLength = 25
Properties
Property Value type What it is
pixelLength number Read-write. The length in pixels this scale equates to.
logicalLength number Read-write. The logical length this scale equates to.
logicalUnits string Read-write. The logical units for this scale.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 137
NoColor
Represents a missing color object, used in the SolidColor object.
Properties
Property Value type What it is
typename string Read-only. The class name of the referenced noColor
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 138
Notifier
An event-handler object that tells a script to execute specified code when a specified event occurs.
Notifiers must be enabled using the Application.notifiersEnabled property.
Note: Events that occur within scripts do not generally trigger notifiers, because they occur inside a "play
script" event.
Properties
Property Value type What it is
event string Read-only. The event identifier, a four-character code or a
unique string.
For a list of four-character codes, see Appendix A: Event ID
Codes.
eventClass string Read-only. The class identifier, a four-character code or a
unique string.
When an event applies to multiple types of objects, use this
propery to distinguish which object this notifier applies to.
For example, the Make event ("Mk ") can apply to
documents ("Dcmn"), channels ("Chnl") and other objects.
eventFile File Read-only. The path to the file to execute when the event
occurs and activates the notifier.
parent Application Read-only. The containing application.
typename string Read-only. The class name of the referenced object.
Methods
Method Parameter type Returns What it does
remove Deletes this object.
()
You can also remove a Notifier object
from the Script Events Manager
drop-down list by deleting the file named
Script Events Manager.xml from the
Photoshop preferences folder. See Adobe
Photoshop help for more information.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 139
Notifiers
The collection of Notifier objects in the document. Access through the Application.notifiers collection
property. For example:
var notRef = app.notifiers.add("OnClickGoButton", eventFile)
Properties
Property Value type What it is
length number Read-only. The number of elements in the notifiers
collection.
parent Application Read-only. The notifiers object’s container
typename string Read-only. The class name of the referenced notifiers object.
Methods
Method Parameter type Returns What it does
add Notifier Creates a notifier object and adds it to this
(event, string collection.
eventFile File
[, eventClass]) string event defines the class ID of the event: use a
4-characters code or a unique string. See
Appendix A: Event ID Codes.
eventFile defines the script file that
executes when the event occurs.
When an event applies to multiple types of
objects, use the eventClass (a 4-character ID
or unique string) to distinguish which object
this Notifier applies to. For example, the
Make event ("Mk ") applies to documents
("Dcmn"), channels ("Chnl") and other
objects.
PathItem
A path or drawing object, such as the outline of a shape or a straight or curved line, which contains sub
paths that define its geometry.
Access through the collection in the Document.pathItems property. For example, this selects a named
path item:
var currentPathItem = app.activeDocument.pathItems.getByName("myPath");
currentPathItem.select()
Create these objects by passing a set of SubPathInfo objects to the PathItems.add() method. This method
creates a SubPathItem object for each SubPathInfo object, and creates and returns a new PathItem object
for the path represented by all of the subpaths.
Properties
Property Value type What it is
kind PathKind Read-write. The type.
name string Read-write. The name.
parent Document Read-only. The containing document.
subPathItems SubPathItems Read-only. The contained sub-path objects.
typename string Read-only. The class name of the referenced
pathItem object.
Methods
Method Parameter type Returns What it does
deselect Deselects this pathItem
() object.
duplicate Duplicates this
(name) string pathItem object with
the new name.
fillPath Fills the area enclosed by
([fillColor] SolidColor this path.
[, mode] ColorBlendMode
[, opacity] number [0..100] opacity is a percentage.
[, preserveTransparency] boolean
number [0.0..250.0] feather is in pixels.
[, feather]
[, wholePath] boolean
boolean If wholePath is true, all
[, antiAlias])
subpaths are used when
doing the fill (default:
true).
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 141
Paths.jsx
//line 1--it’s a straight line so the coordinates for anchor, left, and right
//for each point have the same coordinates
var lineArray = new Array()
lineArray[0] = new PathPointInfo
lineArray[0].kind = PointKind.CORNERPOINT
lineArray[0].anchor = Array(100, 100)
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 142
lineArray[0].leftDirection = lineArray[0].anchor
lineArray[0].rightDirection = lineArray[0].anchor
// line 2
var lineArray2 = new Array()
lineArray2[0] = new PathPointInfo
lineArray2[0].kind = PointKind.CORNERPOINT
lineArray2[0].anchor = Array(150, 200)
lineArray2[0].leftDirection = lineArray2[0].anchor
lineArray2[0].rightDirection = lineArray2[0].anchor
PathItems
The collection of PathItem objects in a document.
Access through the Document.pathItems collection property. For example, this creates a new path item
using a previously-defined set of subpaths:
app.activeDocument.pathItems.add("myPath", lineSubPathInfoArray);
Properties
Property Value type What it is
length number Read-only. The number of pathItem objects in the
pathItems collection.
Methods
Method Parameter type Returns What it does
add PathItem Creates a new path item object and adds it
(name, string to this collection.
entirePath) array of SubPathInfo
A new SubPathItem object is created for
each SubPathInfo object provided in
entirePath, and those SubPathItem
objects are added to the subPathItems
collection of the returned PathItem.
getByName PathItem Get the first element in the pathItems
(name) string collection with the provided name.
removeAll Removes all pathItem objects from the
() pathItems collection.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 145
PathPoint
Represents the anchor and control-handle endpoints for a path segment. Each point (the anchor point,
left-direction point, and right-direction point) is an array containing X and Y position coordinates.
? Use the PathPoint object to retrieve information about the points that describe existing path
segments. The properties are read-only. Access PathPoint objects through the SubPathItem.pathPoints
property.
? Use PathPointInfo with PathItems.add() to create path points. The properties are writeable.
For paths that are straight segments (not curved), the coordinates of all three points are the same. For
curved segements, the the coordinates are different. The difference between the anchor point and the left
or right direction points determines the arc of the curve. You use the left direction point to bend the curve
"outward" or make it convex; you use the right direction point to bend the curve "inward" or make it
concave.
Properties
Property Value type What it is
anchor array of number Read-only. The X and Y coordinates of the anchor point of the
curve.
kind PointKind Read-only. The role (corner or smooth) this point plays in the
containing path segment.
leftDirection array of number Read-only. The location of the left-direction endpoint (’in’
position).
parent SubPathItem Read-only. The containing subpath object.
rightDirection array of number Read-only. The location of the right-direction endpoint (’out’
position).
typename string Read-only. The class name of the referenced PathPoint
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 146
PathPointInfo
Used to create a PathPoint, which represents the anchor and control-handle endpoints for a path segment.
Each point (the anchor point, left-direction point, and right-direction point) is an array containing X and Y
position coordinates.
? Use the JavaScript new operator to create these objects, and store them in the
SubPathInfo.entireSubPath property before using that object to create a path item with
PathItems.add().
See the PathPointInfo sample script below.
? The resulting SubPathItem objects contain the resulting PathPoint objects. Use the PathPoint object to
retrieve information about the points that describe existing path segments. The properties are
read-only.
For paths that are straight segments (not curved), the coordinates of all three points are the same. For
curved segements, the the coordinates are different. The difference between the anchor point and the left
or right direction points determines the arc of the curve. You use the left direction point to bend the curve
"outward" or make it convex; you use the right direction point to bend the curve "inward" or make it
concave.
Properties
Property Value type What it is
anchor array of number Read-write. The X and Y coordinates of the anchor point of
the curve.
kind PointKind Read-write. The role (corner or smooth) this point plays in the
containing path segment.
leftDirection array of number Read-write. The location of the left-direction endpoint (’in’
position).
rightDirection array of number Read-write. The location of the right-direction endpoint (’out’
position).
typename string Read-only. The class name of the referenced PathPointInfo
object.
PathPoints
A collection of PathPoint objects that define a subpath, kept in the SubPathItem.pathPoints property.
Properties
Property Value type What it is
length number Read-only. The number of elements in the collection.
parent SubPathItem Read-only. The containing subpath object.
typename string Read-only. The class name of the referenced PathPoints
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 149
PDFOpenOptions
Options for opening a document in generic Adobe PDF format using the Application.open() method.
Properties
Property Value type What it is
antiAlias boolean Read-write. True to use antialias.
bitsPerChannel BitsPerChannelType Read-write. The number of bits per channel.
PDFSaveOptions
Options for saving a document in Adobe PDF format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels
with the file.
annotations boolean Read-write. True to save comments with the
file.
colorConversion boolean Read-write. True to convert the color profile
to a destination profile.
convertToEightBit boolean Read-write. True to convert a 16-bit image
to 8-bit for better compatibility with other
applications.
description string Read-write. Description of the save options
to use.
destinationProfile string Read-write. Description of the final RGB or
CMYK output device, such as a monitor or a
press standard.
downgradeColorProfile boolean DEPRECATED for Adobe Photoshop.
downSample PDFResample Read-write. The down sample method to
use.
downSampleSize number Read-write. The size to downsample images
if they exceed the limit in pixels per inch.
downSampleSizeLimit number Read-write. Limits downsampling or
subsampling to images that exceed this
value in pixels per inch.
embedColorProfile boolean Read-write. True to embed the color profile
in the document.
embedFonts boolean DEPRECATED for Adobe Photoshop.
embedThumbnail boolean Read-write. True to include a small preview
image in Adobe PDF files.
encoding PDFEncoding Read-write. The type of compression to use
(default: PDFEncoding.PDFZIP).
interpolation boolean DEPRECATED for Adobe Photoshop.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 151
PhotoCDOpenOptions
DEPRECATED in Adobe Photoshop. Kodak PhotoCD is now found in the Goodies folder on the Adobe
Photoshop Install DVD.
Options for opening a document in Kodak Photo CD (PCD) format (including high-resolution files from Pro
Photo CD discs) using the Application.open() method.
Properties
Property Value type What it is
colorProfileName string Read-write. The profile to use when reading the
image.
colorSpace PhotoCDColorSpace Read-write. The colorspace for the image.
orientation Orientation Read-write. The image orientation.
pixelSize PhotoCDSize Read-write. The image dimensions.
resolution number Read-write. The image resolution (in pixels per
inch).
typename string Read-only. The class name of the referenced
photoCDOpenOptions object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 154
PhotoshopSaveOptions
Options for saving a document in PSD format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels.
annotations boolean Read-write. True to save the annotations.
embedColorProfile boolean Read-write. True to embed the color profile in the
document.
layers boolean Read-write. True to preserve the layers.
spotColors boolean Read-write. True to save the spot colors.
typename string Read-only. The class name of the referenced
photoshopSaveOptions object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 155
PICTFileSaveOptions
Options for saving a document in PICT format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels.
compression PICTCompression Read-write. The type of compression to use
(default: PICTCompression.NONE).
embedColorProfile boolean Read-write. True to embed the color profile in the
document.
resolution PICTBitsPerPixels Read-write. The number of bits per pixel.
typename string Read-only. The class name of the referenced
PICTFileSaveOptions object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 156
PICTResourceSaveOptions
Options for saving a document as a PICT Resource file using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels.
compression PICTCompression Read-write. The type of compression to use (default:
PICTCompression.NONE).
PicturePackageOptions
Options for a picture package created with Application.makePicturePackage().
Properties
Property Value type What it is
content PicturePackageTextType Read-write. The content information (default:
PicturePackageTextType.NONE).
PixarSaveOptions
Options for saving a document in Pixar format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha
channels.
typename string Read-only. The class name of the
referenced PixarSaveOptions
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 159
PNGSaveOptions
Options for saving a document in PNG format using the Document.saveAs() method.
Properties
Property Value type What it is
compression number [0..9] Read-write. The compression value (default: 0).
interlaced boolean Read-write. True to interlace rows (default: false).
typename string Read-only. The class name of the referenced
PNGSaveOptions object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 160
Preferences
Represents application preferences for Photoshop. Access this object through the Application.preferences
property. For example:
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
Setting values in this object is equivalent to selecting Edit > Preferences (in Windows) or Photoshop >
Preferences (in Mac OS) in the Adobe Photoshop application. For explanations of individual settings, see
Adobe Photoshop Help.
Properties
Property Value type What it is
additionalPluginFolder File Read-write. The path to an additional
plug-in folder.
Valid only when
useAdditionalPluginFolder = true.
appendExtension SaveBehavior Read-write. The preferred policy for
writing file extensions in Windows.
askBeforeSavingLayeredTIFF boolean Read-write. True to ask the user to verify
layer preservation options when saving a
file in TIFF format.
autoUpdateOpenDocuments boolean Read-write. True to automatically update
open documents.
beepWhenDone boolean Read-write. True to beep when a process
finishes.
colorChannelsInColor boolean Read-write. True to display component
channels in the Channels palette in color.
colorPicker ColorPicker Read-write. The preferred color selection
tool.
columnGutter number [0.1..600.0] Read-write. The width of the column
gutters (in points).
columnWidth number [0.1..600.0] Read-write. Column width (in points)
createFirstSnapshot boolean Read-write. True to automatically make
the first snapshot when a new document
is created.
dynamicColorSliders boolean Read-write. True if dynamic color sliders
appear in the Color palette.
editLogItems EditLogItemsType Read-write. The preferred level of detail
in the history log. Valid only when
useHistoryLog = true.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 161
PresentationOptions
Options for Adobe PDF presentations created using Application.makePDFPresentation().
Properties
Property Value type What it is
autoAdvance boolean Read-write. True to auto advance images when when
viewing the presentation (default: true).
Valid only when presentation = true.
includeFilename boolean Read-write. True to include the file name for the image
(default: false).
interval number [1..60] Read-write. The time in seconds before the view is auto
advanced (default: 5).
Valid only when autoAdvance = true.
loop boolean Read-write. True to begin the presentation again after
the last page (default: false).
Valid only when autoAdvance = true.
magnification MagnificationType Read-write. The magnification type to use when viewing
the image.
PDFFileOptions PDFSaveOptions Read-write. Options to use when creating the PDF file.
presentation boolean Read-write. True if the output will be a presentation
(default: false); when false, the output is a Multi-Page
document.
transition TransitionType Read-write. The method for transition from one image to
the next (default: TransitionType.NONE).
Valid only when autoAdvance = true. .
typename string Read-only. The class name of the referenced
PresentationOptions object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 165
RawFormatOpenOptions
Options for opening a document in RAW format using the Application.open() method.
Properties
Property Value type What it is
bitsPerChannel number Read-write. The number of bits for each channel.
The only valid values are BitsPerChannelType.EIGHT
or BitsPerChannelType.SIXTEEN.
byteOrder ByteOrder Read-write. The order in which multibyte values are
read.
Valid only when bitsPerChannel =
BitsPerChannelType.SIXTEEN.
channelNumber number [1..56] Read-write. The number of channels in the image. The
value of cannot exceed the number of channels in the
image.
When bitsPerChannel =
BitsPerChannelType.SIXTEEN, the only valid values
are 1, 3, or 4.
headerSize number Read-write. The number of bytes of information that
[0..1919999]
will appear in the file before actual image information
begins; that is, the number of zeroes inserted at the
beginning of the file as placeholders.
height number Read-write. The height of the image (in pixels).
interleaveChannels boolean Read-write. True to store color values sequentially.
retainHeader boolean Read-write. True to retain the header when saving.
Valid only when headerSize is 1 or greater.
typename string Read-only. The class name of the referenced
RawFormatOpenOptions object.
RawSaveOptions
Options for saving a document in RAW format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True if alpha channels should be saved.
spotColors boolean Read-write. True if the spot colors should be saved.
typename string Read-only. The class name of the referenced RawSaveOptions
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 167
RGBColor
Defines an RGB color, used in the SolidColor object.
Properties
Property Value type What it is
blue number [0..255] Read-write. The blue color value (default: 255).
green number [0..255] Read-write. The green color value (default: 255)
hexValue string Read-write. The hexadecimal representation of the color.
red number [0..255] Read-write. The red color value (default: 255)
typename string Read-only. The class name of the referenced RGBColor object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 168
Selection
The selected area of a document or layer. Access through the Document.selection property. For example:
app.activeDocument.selection.fill(app.foregroundColor)
Many of the properties and methods use the UnitValue type, which combines measurement values with
the measurement unit. For information about this type, see the JavaScript Tools Guide.
Properties
Property Value type What it is
bounds array of UnitValue Read-only. The bounding rectangle of the entire selection.
parent Document Read-only. The object's container.
solid boolean Read-only. True if the bounding rectangle is a solid.
typename string Read-only. The class name of the referenced selection
object.
Methods
Method Parameter type Returns What it does
clear Clears the selection and
() does not copy it to the
clipboard.
contract Contracts (reduces) the
(by) UnitValue selection by the specified
amount.
copy Copies the selection to the
([merge]) boolean clipboard. When the
optional argument is used
and set to true, a merged
copy is performed (all visible
layers in the selection are
copied).
cut Clears the current selection
() and copies it to the
clipboard.
deselect Deselects the current
() selection.
expand Expands the selection by the
(by) UnitValue specified amount.
feather Feathers the edges of the
(by) UnitValue selection by the specified
amount.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 169
Selection.jsx
//Create variables for the 800 pixel board divided in even 100 x 100 squares
var docSize = 800
var cells = 8
var cellSize = docSize / cells
// Select a square
selRegion = Array(Array(h, v),
Array(h + cellSize, v),
Array(h + cellSize, v + cellSize),
Array(h, v + cellSize),
Array(h, v))
SGIRGBSaveOptions
Options for saving a document in SGIRGB format using the Document.saveAs() method.
Note: The SGIRGB format is not installed automatically with Adobe Photoshop.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha
channels.
spotColors boolean Read-write. True to save the spot
colors.
typename string Read-only. The class name of the
referenced SGIRGBSaveOptions
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 174
SolidColor
A color definition used in the document. Maps a color to equivalents in all available color models.
? Used in Application.backgroundColor and foregroundColor properties, in Channel.color, in
ColorSampler.color, and in TextItem.color
? Passed to PathItem.fillPath(), Selection.fill(), and Selection.stroke().
Properties
Property Value type What it is
cmyk CMYKColor Read-write. The CMYK color mode.
gray GrayColor Read-write. The Grayscale color mode.
hsb HSBColor Read-write. The HSB color mode.
lab LabColor Read-write. The LAB color mode.
model ColorModel Read-write. The color model.
nearestWebColor RGBColor Read-only. The nearest web color to the current color.
rgb RGBColor Read-write. The RGB color mode.
typename string Read-only. The class name of the referenced SolidColor
object.
Methods
Method Parameter type Returns What it does
isEqual boolean True if the SolidColor object is visually
(color) SolidColor equal to the specified color.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 175
SubPathInfo
An array of PathPoint objects that describes a straight or curved segment of a path, used to create a
SubPathItem.
Pass an array of these objects to the PathItems.add() method. This method creates a SubPathItem object
for each SubPathInfo object, and creates and returns a new PathItem object for the path represented by
all of the subpaths.
? Use SubPathInfo to create subpaths; the properties are writeable.
? Use the SubPathItem object to retrieve information about existing subpaths. The properties are
read-only.
Properties
Property Value type What it is
closed boolean Read-write. True if the path describes an enclosed area.
entireSubPath array of PathPoint Read-write.
operation ShapeOperation Read-write. The subpath’s operation on other
subpaths. Specifies how to combine the shapes if the
destination path already has a selection.
typename string Read-only. The class name of the referenced
SubPathInfo object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 176
SubPathItem
Represents a subpath; a collection of subpaths make up a PathItem.
Create these objects by passing SubPathInfo objects to the PathItems.add() method. This method creates
a SubPathItem object for each SubPathInfo object, and creates and returns a new PathItem object for the
path represented by all of the subpaths. Access these objects in the PathItem.subPathItems collection.
? Use the SubPathItem object to retrieve information about existing subpaths. The properties are
read-only.
? Use SubPathInfo to create subpaths; the properties are writeable.
Properties
Property Value type What it is
closed boolean Read-only. True if the path is closed.
operation ShapeOperation Read-only. How this object behaves when it intersects
another SubPathItem object. Specifies how to combine the
shapes if the destination path already has a selection.
parent PathItem Read-only. The object's container.
pathPoints PathPoints Read-only. The PathPoints collection.
typename string Read-only. The class name of the referenced SubPathItem
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 177
SubPathItems
A collection of SubPathItem objects that make up a PathItem. Access this object in the
PathItem.subPathItems collection property.
? Use SubPathInfo to create subpaths; the properties are writeable.
? Use the SubPathItem object to retrieve information about existing subpaths. The properties are
read-only.
Properties
Property Value type What it is
length number Read-only. The number of elements in the collection.
parent PathItem Read-only. The containing path item.
typename string Read-only. The class name of the referenced SubPathItems
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 178
TargaSaveOptions
Options for saving a document in TGA (Targa) format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels.
resolution TargaBitsPerPixels Read-write. The number of bits per pixel (default:
TargaBitsPerPixels.TWENTYFOUR).
TextFont
Describes a font that is available to the application. Access this object in the Application.fonts collection.
For example:
var myFont = app.fonts.getByName("ArialMT");
Properties
Property Value type What it is
family string Read-only. The font family.
name string Read-only. The name of the font.
parent Application Read-only. The containing application.
postScriptName string Read-only. The PostScript name of the font.
style string Read-only. The font style.
typename string Read-only. The class name of the referenced TextFont
object.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 180
TextFonts
The collection of fonts available on your computer. Fonts are represented by TextFont objects. Access this
object in the Application.fonts collection property. For example, this displays the number of available
fonts:
alert(app.fonts.length);
Properties
Property Value type What it is
length number Read-only. The number of elements in the collection.
parent Application Read-only. The containing application.
typename string Read-only. The class name of the referenced TextFonts object.
Methods
Method Parameter type Returns What it does
getByName TextFont Gets the first element in the TextFonts
(name) string collection with the provided name.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 181
TextItem
The text in an ArtLayer object whose kind property is LayerKind.TEXT. Access this object in the
ArtLayer.textItem property. For example:
myLayers[i].textItem.contents = "Layer in " + textArray[i] + " Set Inside "
Many of the properties use the UnitValue type, which combines a measurement value with a
measurement unit. For information about this type, see the JavaScript Tools Guide.
Properties
Property Value type What it is
alternateLigatures boolean Read-write. True to use alternate ligatures.
font string Read-write. The text face of the character. Use the
PostScript Name of the font. See TextFont and use
the postScriptName property.
hangingPunctuation boolean Read-write. True to use Roman hanging punctuation.
height UnitValueX Read-write. The height of the bounding box (unit
value) for paragraph text.
Valid only when kind = TextType.PARAGRAPHTEXT.
horizontalScale number [0..1000] Read-write. Character scaling (horizontal) in
proportion to verticalScale (a percentage value).
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 183
Methods
Method Parameter type Returns What it does
convertToShape Converts the text item and its containing layer to
() a fill layer with the text changed to a clipping
path.
createPath Creates a clipping path from the outlines of the
() actual text items (such as letters or words).
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 188
TiffSaveOptions
Options for saving a document in TIFF format using the Document.saveAs() method.
Properties
Property Value type What it is
alphaChannels boolean Read-write. True to save the alpha channels.
annotations boolean Read-write. True to save the annotations.
byteOrder ByteOrder Read-write. The order in which the document’s
multibyte values are read (default:
ByteOrder.MACOS in Mac OS, ByteOrder.IBM
in Windows).
embedColorProfile boolean Read-write. True to embed the color profile in
the document.
imageCompression TIFFEncoding Read-write. The compression type (default:
TIFFEncoding.NONE).
UnitValue
ExtendScript defines the JavaScript class UnitValue to represent measurement values together with their
measurement units; see ‘JavaScript support in Adobe Photoshop’ on page 32. For references details of
these classes, see the JavaScript Tools Guide.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Object Reference 190
xmpMetadata
Camera RAW image XMP metadata.
For camera RAW image files, the XMP metadata is stored in a sidecar file, which is a file in the same folder as
the RAW file with the same base name and an XMP extension.
Properties
Property Value type What it is
parent Document Read-only. The containing document.
rawData string Read-write. A string containing the XMP metadata in
XML (RDF) format. See the XMP Specification for
details of this format.
typename string Read-only. The class name of the referenced
xmpMetadata object.
3 Adobe Photoshop JavaScript
Reference Guide
JavaScript Resource
This section describes the JavaScript resource that enables your JavaScripts to behave like a plug-in. This
includes:
? the ability to specify a menu the script appears in as a command,
? a terminology resource so the script can function with the Action Manager, which allows your script to
record and be automated by scripting parameters,
? a category to enable ordering and grouping of commands within menus, and
? an enable string that indicates whether the command is enabled or disabled given a set of conditions.
? The strings must be valid XML syntax. The "&" character will not work for example. Use the &&
for example to get logical ‘&&’ in the enableinfo block.
Tag Description
<javascriptresource> The resource definition tag.
<name> The command name that appears in the Photoshop menu.
If this tag is not provided in the resource, the name of the command in the
menu defaults to the name of the script.
<menu> The menu the command appears in. If this tag is not provided, the
command appears in the File > Scripts menu.
Note: Currently the only supported values for <menu> are automate,
filter and help. automate puts the script in the File >
Automate menu for example.
<about> A string that appears in an About box, which the user can select from the
Help > About Plug-in menu.
191
Adobe Photoshop
JavaScript Scripting Reference JavaScript Resource 192
Tag Description
<enableinfo> A boolean expression that indicates whether the command is enabled in
the menu. See Enable-info grammar.
Note: If you provide this tag, the menu item is enabled if and only if there
is at least one document open, and the boolean expression
evaluates to true. If you always want the menu item enabled, do not
use this tag.
<eventid> A unique string that identifies the event. Using a UUID will ensure that your
script wont share this identifier with another script.
<category> The category the command appears within in the menu. Used to group
and order commands in the menu. Commands are placed in the menu
alphabetically based on the string in <category>. If two commands use
the same category, they are grouped together.
<terminology> The terminology dictionary for the script to function with the Action
Manager. See the Terminology dictionary.
app.documents.add();
Enable-info grammar
The <enableinfo> tag provides a boolean expression that, when evaluated, indicates whether the
command is enabled in the menu. You can use this expression to enable or disable the menu item based
on various characteristics of the document. The Enable Info grammar is as follows:
<booleanExpression> := <conjunction> { "||" <conjunction> }
Operator precedence is shown in the following table. Operators are listed with the highest order of
precedence at the top of the table
Operator Description
|| Or
&& And
+ - Addition or subtraction
* / Multiply or divide
< <= >= > Less than, less than or equal, greater than or equal, greater than
== != Equals, or does not equal.
(..) in() max() min() Functions
unary + - ! Unary operators: increment, decrement, not
The grammar provides variables and constants that you can use in the <enableinfo> expression. The
following table provides a list of the constants that are available.
The following table show the set of variables you can use in the <enableinfo> expression. The value of
these variables is set based on the properties of the active document.
Boolean values are treated as in C/C++, where non-zero values are true, and zero is false, with the
exception that an undefined value is also false.
? A terminology dictionary that maps your script’s user interface to human readable text, providing text
and type information for each parameter the script uses.
? Code to read parameter information when it comes from the Action Manager, rather than from the
user-interface, and code to write parameter information to the Action Manger. This code uses the
Action Manager classes ActionDescriptor, ActionList, and ActionReference.
See Conditional Mode Change.jsx for an example of a script that can record and be automated by
scripting parameters. This file can be found in the Presets/Scripts folder.
Terminology dictionary
The JavaScript resource provides a <terminology> tag that allows you to provide the terminology
dictionary for your script. The first step in creating a terminology dictionary is to review your script’s user
interface, and create human-readable strings for each element in your user interface.
For example, in the Conditional Mode Change command, the user interface requests a source mode and a
target mode. Both source mode and target mode have several options. All of these elements of the user
interface need to have entries in the terminology dictionary.
The terminology dictionary is created in a PDF dictionary format, with the following entries, and must have
the following format in the <javascriptresource>:
<terminology><![CDATA[<<<
/Version integer
/Events <<event dictionary>>
/Classes <<class dictionary>>
/Enumerations <<enumeration dictionary>>
>>> ]]></terminology>
Note: The information in the terminology tag needs to be wrapped in a CDATA block so the xml parser will
ignore "/" and other tags that appear in the terminology.
The defintions for events, classes and enumerations dictionaries are provided below.
Adobe Photoshop
JavaScript Scripting Reference JavaScript Resource 196
The annotSizeClass has two properties: width, and height, both of type floatType. The enumeration
annotType has three values: annotUnknown, annotText, and annotSound.
<terminology><![CDATA[<<<
/Version 1
/Events
/newAnnot [(New Annotation) <<
/annotType [(Type) /annotType]
/at [(At) /Point]
/size [(Size) /annotSizeClass] >>]
/Classes
/annotSizeClass [(Size) <<
/width [(Width) /floatType]
/height [(Height) /floatType]
>>]
/Enumerations
/annotType <<
/annotUnknown (Unknown)
/annotText (Text)
/annotSound (Sound)
>>> ]]></terminology>
4 Scripting Constants
This section lists and describes the enumerations defined for use with Adobe Photoshop JavaScript
properties and methods.
Pass to ArtLayer.selectiveColor().
AnchorPosition BOTTOMCENTER The point around which to transform
BOTTOMLEFT an object. This is the point that does
BOTTOMRIGHT
MIDDLECENTER not move when an object is rotated or
MIDDLELEFT resized using methods in ArtLayer,
MIDDLERIGHT LayerSet, and Selection, or when the
TOPCENTER entire canvas is resized with
TOPLEFT
TOPRIGHT Document.resizeCanvas().
199
Adobe Photoshop
JavaScript Scripting Reference Scripting Constants 200
The following table lists events and their four-character ID codes or string identifiers for use with the
notifier object.
Note: Do not include single quotes ( ' ) with four-character IDs in your code. The single quotes are
used in this table to illustrate the placement of required spaces in codes that do not contain four
letters. However, string identifiers, which are longer than four characters, require double quotes in
the code.
Tip: If you can’t find the event you want to use for notification in this table, you can use ScriptListener to
determine the event ID code. See the ScriptListener documentation in the Action Manager chapter of
the Photoshop Scripting Guide.
Average 'Avrg'
ApplyStyle 'ASty'
Assert 'Asrt'
AccentedEdges 'AccE'
AddNoise 'AdNs'
AddTo 'AddT'
Align 'Algn'
AngledStrokes 'AngS'
ApplyImage 'AppI'
BasRelief 'BsRl'
Batch 'Btch'
BatchFromDroplet 'BtcF'
BlurMore 'BlrM'
Border 'Brdr'
Brightness 'BrgC'
CanvasSize 'CnvS'
ChalkCharcoal 'ChlC'
ChannelMixer 'ChnM'
218
Adobe Photoshop
JavaScript Scripting Reference Appendix A: Event ID Codes 219
Chrome 'Chrm'
Clear 'Cler'
Clouds 'Clds'
ColorBalance 'ClrB'
ColorHalftone 'ClrH'
ColorRange 'ClrR'
ColoredPencil 'ClrP'
ContactSheet "0B71D221-F8CE-11d2-B21B-0008C75B322C"
ConteCrayon 'CntC'
Contract 'Cntc'
ConvertMode 'CnvM'
Copy 'copy'
CopyEffects 'CpFX'
CopyMerged 'CpyM'
CopyToLayer 'CpTL'
Craquelure 'Crql'
CreateDroplet 'CrtD'
Crop 'Crop'
Crosshatch 'Crsh'
Crystallize 'Crst'
Curves 'Crvs'
Custom 'Cstm'
CutToLayer 'CtTL'
DarkStrokes 'DrkS'
DeInterlace 'Dntr'
DefinePattern 'DfnP'
Defringe 'Dfrg'
Desaturate 'Dstt'
Adobe Photoshop
JavaScript Scripting Reference Appendix A: Event ID Codes 220
Despeckle 'Dspc'
DifferenceClouds 'DrfC'
DiffuseGlow 'DfsG'
DisableLayerFX 'dlfx'
Displace 'Dspl'
Distribute 'Dstr'
Draw 'Draw'
DryBrush 'DryB'
Duplicate 'Dplc'
DustAndScratches 'DstS'
Emboss 'Embs'
Equalize 'Eqlz'
Exchange 'Exch'
Expand 'Expn'
Export 'Expr'
Jumpto 'Jpto'
ExportTransparentImage "02879e00-cb66-11d1-bc43-0060b0a13dc4"
Extrude 'Extr'
Fade 'Fade'
Feather 'Fthr'
Fibers 'Fbrs'
FilmGrain 'FlmG'
Filter 'Fltr'
FindEdges 'FndE'
FitImage "3caa3434-cb67-11d1-bc43-0060b0a13dc4"
FlattenImage 'FltI'
Flip 'Flip'
Fragment 'Frgm'
Fresco 'Frsc'
Adobe Photoshop
JavaScript Scripting Reference Appendix A: Event ID Codes 221
Get 'getd'
GlowingEdges 'GlwE'
Gradient 'Grdn'
GradientMap 'GrMp'
GraphicPen 'GraP'
Group 'GrpL'
Grow 'Grow'
HalftoneScreen 'HlfS'
HighPass 'HghP'
HSBHSL 'HsbP'
HueSaturation 'HStr'
ImageSize 'ImgS'
Import 'Impr'
InkOutlines 'InkO'
Intersect 'Intr'
IntersectWith 'IntW'
Inverse 'Invs'
Invert 'Invr'
LensFlare 'LnsF'
Levels 'Lvls'
LightingEffects 'LghE'
MergeLayers 'Mrg2'
MergeLayersOld 'MrgL'
MergeSpotChannel 'MSpt'
MergeVisible 'MrgV'
Adobe Photoshop
JavaScript Scripting Reference Appendix A: Event ID Codes 222
ModeChange "8cba8cd6-cb66-11d1-bc43-0060b0a13dc4"
Mosaic_PLUGIN 'MscT'
MotionBlur 'MtnB'
Move 'move'
NTSCColors 'NTSC'
NeonGlow 'NGlw'
NotePaper 'NtPr'
Notify 'Ntfy'
Null typeNull
OceanRipple 'OcnR'
Offset 'Ofst'
PaintDaubs 'PntD'
PaletteKnife 'PltK'
Paste 'past'
PasteEffects 'PaFX'
PasteInto 'PstI'
PasteOutside 'PstO'
Patchwork 'Ptch'
Photocopy 'Phtc'
PicturePackage "4C1ABF40-DD82-11d2-B20F-0008C75B322C"
Pinch 'Pnch'
Plaster 'Plst'
PlasticWrap 'PlsW'
Pointillize 'Pntl'
Posterize 'Pstr'
Previous 'Prvs'
Print 'Prnt'
ProfileToProfile 'PrfT'
Purge 'Prge'
Quit 'quit'
RadialBlur 'RdlB'
Rasterize 'Rstr'
RasterizeTypeSheet 'RstT'
RemoveBlackMatte 'RmvB'
RemoveLayerMask 'RmvL'
RemoveWhiteMatte 'RmvW'
ReplaceColor 'RplC'
Reset 'Rset'
ResizeImage "1333cf0c-cb67-11d1-bc43-0060b0a13dc4"
Reticulation 'Rtcl'
Revert 'Rvrt'
Ripple 'Rple'
Rotate 'Rtte'
RoughPastels 'RghP'
Save 'save'
Select 'slct'
SelectiveColor 'SlcC'
Set 'setd'
SharpenEdges 'ShrE'
Sharpen 'Shrp'
SharpenMore 'ShrM'
Similar 'Smlr'
SmartBlur 'SmrB'
Adobe Photoshop
JavaScript Scripting Reference Appendix A: Event ID Codes 224
SmudgeStick 'SmdS'
Solarize 'Slrz'
Spherize 'Sphr'
SplitChannels 'SplC'
Sponge 'Spng'
SprayedStrokes 'SprS'
StainedGlass 'StnG'
Stamp 'Stmp'
Stop 'Stop'
Stroke 'Strk'
Subtract 'Sbtr'
SubtractFrom 'SbtF'
Sumie 'Smie'
TakeMergedSnapshot 'TkMr'
TakeSnapshot 'TkSn'
TextureFill 'TxtF'
Texturizer 'Txtz'
Threshold 'Thrs'
TornEdges 'TrnE'
TraceContour 'TrcC'
Transform 'Trnf'
Trap 'Trap'
Twirl 'Twrl'
Underpainting 'Undr'
Undo 'undo'
Ungroup 'Ungr'
Unlink 'Unlk'
UnsharpMask 'UnsM'
Variations 'Vrtn'
Wait 'Wait'
Adobe Photoshop
JavaScript Scripting Reference Appendix A: Event ID Codes 225
Watercolor 'Wtrc'
Wave 'Wave'
ZigZag 'ZgZg'
BackLight 'BacL'
FillFlash 'FilE'
ColorCast 'ColE'
Index
A available memory 46
Action Manager 195 Average filter 57
actions
command lists 40 B
descriptions 43 background color
descriptors 37 application 45
playing 47 galleries 112
active document 45 background layers 55
activePrinter 98 backgroundColor 98
Add Noise filter baseline shift 181
adjustments batch command 47
brightness 57 batches
color 199 destination folder 68, 199
color balance 57, 63 specifying options 68
contrast 57, 61 beeping 160
curves 57 bitmap documents
highlights 64 converting to 200
levels 57, 61 depth type 200
shadows 64 halftone type 200
temperature 63 opening 209
Adobe Illustrator, exporting paths to 107 saving 71
alpha channels bitmap images
defined 74 See bitmap documents
from transparency (TIFF documents) 188 black and white images 64
opacity 74 bleedWidth 98
saving blending modes
in BMP documents 71 layer sets 131
in PDF documents 150 layers 55
in PICT documents 155 Blur filter 57
in PICT resources 156 blur filters
in Pixar documents 158 Average 57
in PSD documents 154 Blur More 57
in RAW documents 166 Gaussian Blur 58
in SGIRGB documents 173 Lens Blur 59
in Targa documents 178 Motion Blur 60
in TIFF documents 188 Radial Blur 60
anchor points Smart Blur 61
adding 145 Blur More filter 57
annotations, importing 94 BMP documents
anti aliasing See bitmap documents
text 181 brightness 57
application adjusting 57
activating 47 equalizing 62
checking if feature enabled 49 build 45
defaults 160
location 46
preferences 160 C
artLayers, See layers caches
Asian text 162 images 161
authors 101 purging 51
auto kerning 181, 199 camera raw documents
auto leading 186 opening 72
auto spacing, contact sheets 84 settings 201
size options 201
226
Adobe Photoshop
JavaScript Scripting Reference Index 227
canvas settings 45
flipping 94 solid color objects 174
resizing 94 testing if equal 174
canvas, defined 90 visited links 112
caption 98 comments, layer comps 128
captions compatibility, maximizing 161
contact sheets 84 component channels
documents 101 color balance 57
gallery images 113 defined 74
gallery thumbnails 117 listing 90
images 101 See composite channels
centerCropMarks 98 composite channels 74
changeProgressText 47 See component channels
channels Compuserve GIF documents
activating 90 opening 209
adding 76 saving 118
adjusting 57 contact sheets
alpha See alpha channels captions 84
creating 76 columns 84
deleting 74 dimensions 84
displaying in color 160 making 50
duplicating 74 rows 84
making visible 74 contrast
merging 74 adjusting 57
mixing 63 adjusting automatically 61
splitting 95 camera raw settings 72
spot See spot channels midtones 64
types of 74 copies 98
clipping paths copyrights 101
from paths 141 cornerCropMarks 98
from text 187 count items
Clouds filter 57 adding 86
CMYKColor 81 creating 86
color balance, adjusting 63 removing 85
color picker 160 cropping 93
color profiles current tool name 45
changing 93 cursors 162
determining type of 91 curves, adjusting 57
naming 90 Custom filters 57
color profiles, see individual document formats
color samplers
D
adding 83
DCS 1 documents, saving 87
creating 83
De-Interlace filter 58
moving 82
desaturate 62
removing 82
Despeckle filter 58
colorBars 98
dialogs
colorHandling 98
displaying 45
colors
Difference Clouds filter 58
active links 112
Diffuse Glow filter 58
adjusting 199
Displace filter 58
balancing 57
distort filters
channels 74
Diffuse Glow 58
CMYK 81
Displace 58
custom settings 115
Glass Effect 58
in galleries 112
Ocean Ripple 60
inverting 62
Pinch 60
modifying 64
Polar Coordinates 60
none 137
Ripple 60
preserving (GIF only) 118
Shear 61
reduction 108
Adobe Photoshop
JavaScript Scripting Reference Index 228
H J
halftone screen 70 JavaScript
hanging punctuation 182 supported features 32
hardProof 98 JavaScript Resource
High Pass filter 58 Enable Info grammar 192
highlights javascriptresource syntax 191
adjusting 64 javascriptresource tag 191
color balance 57 JPEG
histograms quality 126
channels 74 JPEG documents
history log 163 quality 126
history states saving 126
activating 90 JPEG options
allowing nonlinear 161 scans 126
default number of 162 JPEGSaveOptions 126
snapshot 122 justification 183
suspending 95
HSBColor 124
K
hypenation 183
kerning 181
text
I auto kerning 199
IDs keyboard behavior 161
getting 37
PICT Resource 156
L
property 43
LabColor 127
runtime 47
labels 98
runtime to string 52
languages 183
string to runtime 51
layer comps 128
string to type 51
adding 129
type to char 51
applying 128
Illustrator
in documents 91
See Adobe Illustrator
layer sets
image
adding 133
resizing 95
art layers in 131
image pyramids 188
duplicating 132
images
in documents 91
bitmap 70
linked layers in 131
black and white 64
linking 132
caches 161
locking contents 131
captions 113
moving 132
definition of 90
nesting 131
desaturating 62
opacity 131
equalizing 62
unlinking 132
filetypes 46
layer styles, applying 61
from split channels 95
LayerComps 129
inverting colors 62
layered TIFFdocuments, saving 160
previewing 161
Layers 130
pyramids 188
layers
resizing 94
adding 67
resizing in galleries 114
applying styles 61
thumbnails 117
background 55
indexed color model 125
blending mode 55
IndexedConversionOptions 125
bounds 55
individual document formats, examples 95
clipboard commands 61
installing scripts 33
comps 128
Intent 98
copying 61
interpolate 98
duplicating 62
interpolation 161
flattening 94
grouping 55
Adobe Photoshop
JavaScript Scripting Reference Index 230
in documents 91 N
inverting 62 negative 98
kind 55 noise filters
linking 62 Add Noise
locking contents 55–56 Despeckle 58
making visible 56 Dust and Scratches 58
merging 62 Median Noise 59
merging visible 94 nonlinear history 161
moving 63 notifications
rasterizing 94 events within scripts 138
rasterizing contents 63 notifiers
removing 67 adding 139
resizing 64 event IDs 218
rotating 64 removing 138
saving in PDF documents 150 NTSC filter 60
unlinking 64
LayerSet 131
LayerSets 133 O
layersets Ocean Ripple filter 60
merging 132 Offset filter 60
leading 183, 186 old style type 185
Lens Blur filter opacity
applying 59 channels 74
Lens Flare filter 59 gallery security text 116
letter spacing 182–185 layer fill 55
levels layer sets 131
adjusting 57 layers 56
adjusting automatically 57 picture packages 157
ligatures 181–183 open options
linked layers 62 DICOM format 89
unlinking 64 EPS format 105
links PDF format 149
colors 112 Photo CD format 153
RAW format 72, 165
optimizing 108
M other filters
MacOS Custom 57
filetypes 46 High Pass 58
managed documents 91 Maximum 59
mapBlack 98 Minimum 60
maximizing compatibility 161 Offset 60
Maximum filter 59
Median Noise filter 59
memory 46 P
merging palettes 162
layers 62 pasting 94
visible layers 94 path 46
metadata path items
document 91 adding 144
document object 101 deselecting 140
galleries 115 filling 140
xmp 92, 190 from text 187
methods making selection 141
batch 47 path points 176
midtones selecting 141
color balance 57 specifying path kind 140
Minimum filter 60 stroking 141
Motion Blur filter 60 sub items 140
sub path info 175
sub path items 176
work path from selection 169
Adobe Photoshop
JavaScript Scripting Reference Index 231