Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
bbc
JAVASCRIPT SCRIPTING REFERENCE
© 2007 Adobe Systems Incorporated. All rights reserved.
Adobe® Creative Suite® 3 Photoshop® JavaScript Scripting Reference for Windows® and Macintosh®.
NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consent of Adobe Systems Incorporated. The software described in this document is furnished under license and may only be used or copied in accordance with the terms of such license.
This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization.
Adobe®, the Adobe logo, Acrobat®, GoLive®,InDesign®, Illustrator®, Photoshop® are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Apple®, Mac OS®, and Macintosh® are trademarks of Apple Computer, Inc., registered in the United States and other countries. Microsoft®, and Windows®. are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. JavaScriptTM and all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. UNIX® is a registered trademark of The Open Group.
All other trademarks are the property of their respective owners.
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational content contained in this guide.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.
3
Contents
1 Introduction ............................................................................................................................... 31JavaScript support in Adobe Photoshop CS3 ....................................................................................................................31
Executing scripts ....................................................................................................................................................................31Installing scripts ...............................................................................................................................................................32Executing other scripts ..................................................................................................................................................32
Startup scripts .........................................................................................................................................................................32Changes Since Earlier Versions................................................................................................................................................32
2 JavaScript Object Reference ..................................................................................................... 35Working with the Properties Tables ......................................................................................................................................35
displayDialogs.................................................................................................................................................................35Working with the Methods Tables .........................................................................................................................................35
executeAction.................................................................................................................................................................36Working with Method Parameters ..................................................................................................................................36
ActionDescriptor ..........................................................................................................................................................................37Properties..................................................................................................................................................................................37
count ..................................................................................................................................................................................37typename .........................................................................................................................................................................37
Methods ....................................................................................................................................................................................37clear ....................................................................................................................................................................................37erase ...................................................................................................................................................................................37fromStream......................................................................................................................................................................37getBoolean.......................................................................................................................................................................37getClass .............................................................................................................................................................................37getData..............................................................................................................................................................................37getDouble ........................................................................................................................................................................37getEnumerationType ...................................................................................................................................................37getEnumerationValue..................................................................................................................................................37getInteger.........................................................................................................................................................................37getKey................................................................................................................................................................................37getList ................................................................................................................................................................................37getObjectType................................................................................................................................................................38getObjectValue...............................................................................................................................................................38getPath ..............................................................................................................................................................................38getReference ...................................................................................................................................................................38getString ...........................................................................................................................................................................38getType .............................................................................................................................................................................38getUnitDoubleType......................................................................................................................................................38getUnitDoubleValue.....................................................................................................................................................38hasKey................................................................................................................................................................................38isEqual................................................................................................................................................................................38putBoolean ......................................................................................................................................................................38putClass.............................................................................................................................................................................38putData .............................................................................................................................................................................38putDouble ........................................................................................................................................................................38putEnumerated ..............................................................................................................................................................38
Adobe Photoshop CS3JavaScript Scripting Reference 4
putInteger ........................................................................................................................................................................38putList ................................................................................................................................................................................39putObject..........................................................................................................................................................................39putPath..............................................................................................................................................................................39putReference...................................................................................................................................................................39putString...........................................................................................................................................................................39putUnitDouble................................................................................................................................................................39toStream ...........................................................................................................................................................................39
ActionList.........................................................................................................................................................................................40Properties..................................................................................................................................................................................40
count ..................................................................................................................................................................................40typename .........................................................................................................................................................................40
Methods ....................................................................................................................................................................................40clear ....................................................................................................................................................................................40getBoolean.......................................................................................................................................................................40getClass .............................................................................................................................................................................40getData..............................................................................................................................................................................40getDouble ........................................................................................................................................................................40getEnumerationType ...................................................................................................................................................40getEnumerationValue..................................................................................................................................................40getInteger.........................................................................................................................................................................40getList ................................................................................................................................................................................40getObjectType................................................................................................................................................................40getObjectValue...............................................................................................................................................................41getPath ..............................................................................................................................................................................41getReference ...................................................................................................................................................................41getString ...........................................................................................................................................................................41getType .............................................................................................................................................................................41getUnitDoubleType......................................................................................................................................................41getUnitDoubleValue.....................................................................................................................................................41putBoolean ......................................................................................................................................................................41putClass.............................................................................................................................................................................41putData .............................................................................................................................................................................41putDouble ........................................................................................................................................................................41putEnumerated ..............................................................................................................................................................41putInteger ........................................................................................................................................................................41putList ................................................................................................................................................................................41putObject..........................................................................................................................................................................41putPath..............................................................................................................................................................................41putReference...................................................................................................................................................................42putString...........................................................................................................................................................................42putUnitDouble................................................................................................................................................................42
ActionReference ...........................................................................................................................................................................43Properties..................................................................................................................................................................................43
typename .........................................................................................................................................................................43Methods ....................................................................................................................................................................................43
getContainer ...................................................................................................................................................................43getDesiredClass..............................................................................................................................................................43getEnumeratedType.....................................................................................................................................................43getEnumeratedValue ...................................................................................................................................................43getForm.............................................................................................................................................................................43
Adobe Photoshop CS3JavaScript Scripting Reference 5
getIdentifier .....................................................................................................................................................................43getIndex............................................................................................................................................................................43getName ...........................................................................................................................................................................43getOffset ...........................................................................................................................................................................43getProperty......................................................................................................................................................................43putClass.............................................................................................................................................................................43putEnumerated ..............................................................................................................................................................44putIdentifier.....................................................................................................................................................................44putIndex............................................................................................................................................................................44putName...........................................................................................................................................................................44putOffset...........................................................................................................................................................................44putProperty......................................................................................................................................................................44
Application .....................................................................................................................................................................................45Properties..................................................................................................................................................................................45
activeDocument.............................................................................................................................................................45backgroundColor...........................................................................................................................................................45colorSettings ...................................................................................................................................................................45displayDialogs.................................................................................................................................................................45documents .......................................................................................................................................................................45fonts....................................................................................................................................................................................45foregroundColor ............................................................................................................................................................45freeMemory .....................................................................................................................................................................45locale ..................................................................................................................................................................................45macintoshFileTypes......................................................................................................................................................45measurementLog ..........................................................................................................................................................45name...................................................................................................................................................................................46notifiers .............................................................................................................................................................................46notifiersEnabled.............................................................................................................................................................46path.....................................................................................................................................................................................46playbackDisplayDialogs ..............................................................................................................................................46playbackParameters .....................................................................................................................................................46preferences ......................................................................................................................................................................46preferencesFolder .........................................................................................................................................................46recentFiles ........................................................................................................................................................................46scriptingBuildDate ........................................................................................................................................................46scriptingVersion .............................................................................................................................................................46typename .........................................................................................................................................................................46version ...............................................................................................................................................................................46windowsFileTypes.........................................................................................................................................................46
Methods ....................................................................................................................................................................................47batch ..................................................................................................................................................................................47beep....................................................................................................................................................................................47bringToFront ...................................................................................................................................................................47charIDToTypeID..............................................................................................................................................................47doAction ...........................................................................................................................................................................47eraseCustomOptions....................................................................................................................................................47executeAction.................................................................................................................................................................47executeActionGet..........................................................................................................................................................47featureEnabled ...............................................................................................................................................................48getCustomOptions........................................................................................................................................................48load .....................................................................................................................................................................................48
Adobe Photoshop CS3JavaScript Scripting Reference 6
makeContactSheet........................................................................................................................................................48makePDFPresentation .................................................................................................................................................48makePhotoGallery.........................................................................................................................................................48makePhotomerge..........................................................................................................................................................48makePicturePackage....................................................................................................................................................48open ...................................................................................................................................................................................49openDialog ......................................................................................................................................................................49purge..................................................................................................................................................................................49putCustomOptions .......................................................................................................................................................49refresh................................................................................................................................................................................49stringIDToTypeID...........................................................................................................................................................49typeIDToCharID..............................................................................................................................................................50typeIDToStringID ...........................................................................................................................................................50
ArtLayer............................................................................................................................................................................................53Properties..................................................................................................................................................................................53
allLocked...........................................................................................................................................................................53blendMode.......................................................................................................................................................................53bounds...............................................................................................................................................................................53fillOpacity..........................................................................................................................................................................53grouped ............................................................................................................................................................................53isBackgroundLayer........................................................................................................................................................53kind .....................................................................................................................................................................................53linkedLayers.....................................................................................................................................................................54name...................................................................................................................................................................................54opacity ...............................................................................................................................................................................54parent.................................................................................................................................................................................54pixelsLocked....................................................................................................................................................................54positionLocked...............................................................................................................................................................54textItem.............................................................................................................................................................................54transparentPixelsLocked.............................................................................................................................................54typename .........................................................................................................................................................................54visible .................................................................................................................................................................................54
Methods ....................................................................................................................................................................................54adjustBrightnessContrast ...........................................................................................................................................54adjustColorBalance .......................................................................................................................................................54adjustCurves....................................................................................................................................................................55adjustLevels .....................................................................................................................................................................55applyAddNoise ...............................................................................................................................................................55applyAverage..................................................................................................................................................................55applyBlur...........................................................................................................................................................................55applyBlurMore ................................................................................................................................................................55applyClouds.....................................................................................................................................................................55applyCustomFilter.........................................................................................................................................................55applyDeInterlace............................................................................................................................................................55applyDespeckle ..............................................................................................................................................................55applyDifferenceClouds................................................................................................................................................55applyDiffuseGlow ..........................................................................................................................................................55applyDisplace..................................................................................................................................................................56applyDustAndScratches..............................................................................................................................................56applyGaussianBlur.........................................................................................................................................................56applyGlassEffect.............................................................................................................................................................56
Adobe Photoshop CS3JavaScript Scripting Reference 7
applyHighPass ................................................................................................................................................................56applyLensBlur .................................................................................................................................................................57applyLensFlare................................................................................................................................................................57applyMaximum ..............................................................................................................................................................58applyMedianNoise ........................................................................................................................................................58applyMinimum ...............................................................................................................................................................58applyMotionBlur ............................................................................................................................................................58applyNTSC........................................................................................................................................................................58applyOceanRipple .........................................................................................................................................................58applyOffset.......................................................................................................................................................................58applyPinch .......................................................................................................................................................................58applyPolarCoordinates ................................................................................................................................................58applyRadialBlur ..............................................................................................................................................................58applyRipple......................................................................................................................................................................58applySharpen..................................................................................................................................................................58applySharpenEdges......................................................................................................................................................59applySharpenMore .......................................................................................................................................................59applyShear .......................................................................................................................................................................59applySmartBlur...............................................................................................................................................................59applySpherize .................................................................................................................................................................59applyStyle.........................................................................................................................................................................59applyTextureFill..............................................................................................................................................................59applyTwirl .........................................................................................................................................................................59applyUnSharpMask.......................................................................................................................................................59applyWave........................................................................................................................................................................59applyZigZag.....................................................................................................................................................................60autoContrast....................................................................................................................................................................60autoLevels ........................................................................................................................................................................60clear ....................................................................................................................................................................................60copy ....................................................................................................................................................................................60cut........................................................................................................................................................................................60desaturate ........................................................................................................................................................................60duplicate ...........................................................................................................................................................................60equalize .............................................................................................................................................................................60invert ..................................................................................................................................................................................60link.......................................................................................................................................................................................60merge.................................................................................................................................................................................61mixChannels....................................................................................................................................................................61move...................................................................................................................................................................................61photoFilter .......................................................................................................................................................................62posterize ...........................................................................................................................................................................62rasterize.............................................................................................................................................................................62remove...............................................................................................................................................................................62resize ..................................................................................................................................................................................62rotate..................................................................................................................................................................................62selectiveColor..................................................................................................................................................................62shadowHighlight ...........................................................................................................................................................62threshold...........................................................................................................................................................................63translate ............................................................................................................................................................................63unlink .................................................................................................................................................................................63
ArtLayers..........................................................................................................................................................................................65
Adobe Photoshop CS3JavaScript Scripting Reference 8
Properties..................................................................................................................................................................................65length.................................................................................................................................................................................65parent.................................................................................................................................................................................65typename .........................................................................................................................................................................65
Methods ....................................................................................................................................................................................65index...................................................................................................................................................................................65add ......................................................................................................................................................................................65getByName ......................................................................................................................................................................65removeAll .........................................................................................................................................................................65
BatchOptions .................................................................................................................................................................................66Properties..................................................................................................................................................................................66
destination .......................................................................................................................................................................66destinationFolder ..........................................................................................................................................................66errorFile .............................................................................................................................................................................66fileNaming........................................................................................................................................................................66macintoshCompatible .................................................................................................................................................66overrideOpen..................................................................................................................................................................66overrideSave....................................................................................................................................................................67startingSerial ...................................................................................................................................................................67suppressOpen.................................................................................................................................................................67suppressProfile ...............................................................................................................................................................67typename .........................................................................................................................................................................67unixCompatible..............................................................................................................................................................67windowsCompatible ....................................................................................................................................................67
BitmapConversionOptions .......................................................................................................................................................68Properties..................................................................................................................................................................................68
angle...................................................................................................................................................................................68frequency..........................................................................................................................................................................68method..............................................................................................................................................................................68patternName...................................................................................................................................................................68resolution..........................................................................................................................................................................68shape..................................................................................................................................................................................68typename .........................................................................................................................................................................68
BMPSaveOptions ..........................................................................................................................................................................69Properties..................................................................................................................................................................................69
alphaChannels ................................................................................................................................................................69depth..................................................................................................................................................................................69flipRowOrder ...................................................................................................................................................................69osType................................................................................................................................................................................69rleCompression ..............................................................................................................................................................69typename .........................................................................................................................................................................69
CameraRAWOpenOptions ........................................................................................................................................................70Properties..................................................................................................................................................................................70
bitsPerChannel ...............................................................................................................................................................70blueHue.............................................................................................................................................................................70blueSaturation ................................................................................................................................................................70brightness.........................................................................................................................................................................70chromaticAberrationBY...............................................................................................................................................70chromaticAberrationRC...............................................................................................................................................70colorNoiseReduction....................................................................................................................................................70colorSpace........................................................................................................................................................................70
Adobe Photoshop CS3JavaScript Scripting Reference 9
contrast .............................................................................................................................................................................70exposure ...........................................................................................................................................................................70greenHue..........................................................................................................................................................................70greenSaturation .............................................................................................................................................................70luminanceSmoothing ..................................................................................................................................................70redHue...............................................................................................................................................................................70redSaturation ..................................................................................................................................................................70resolution..........................................................................................................................................................................70saturation .........................................................................................................................................................................70settings..............................................................................................................................................................................70shadows ............................................................................................................................................................................70shadowTint ......................................................................................................................................................................71sharpness..........................................................................................................................................................................71size ......................................................................................................................................................................................71temperature.....................................................................................................................................................................71tint.......................................................................................................................................................................................71typename .........................................................................................................................................................................71vignettingAmount ........................................................................................................................................................71vignettingMidpoint ......................................................................................................................................................71whiteBalance...................................................................................................................................................................71
Channel ............................................................................................................................................................................................72Properties..................................................................................................................................................................................72
color....................................................................................................................................................................................72histogram .........................................................................................................................................................................72kind .....................................................................................................................................................................................72name...................................................................................................................................................................................72opacity ...............................................................................................................................................................................72parent.................................................................................................................................................................................72typename .........................................................................................................................................................................73visible .................................................................................................................................................................................73
Methods ....................................................................................................................................................................................73duplicate ...........................................................................................................................................................................73merge.................................................................................................................................................................................73remove...............................................................................................................................................................................73
Channels ..........................................................................................................................................................................................74Properties..................................................................................................................................................................................74
length.................................................................................................................................................................................74parent.................................................................................................................................................................................74typename .........................................................................................................................................................................74
Methods ....................................................................................................................................................................................74index...................................................................................................................................................................................74add ......................................................................................................................................................................................74getByName ......................................................................................................................................................................74removeAll .........................................................................................................................................................................74
CMYKColor......................................................................................................................................................................................79Properties..................................................................................................................................................................................79
black ...................................................................................................................................................................................79cyan.....................................................................................................................................................................................79magenta............................................................................................................................................................................79typename .........................................................................................................................................................................79yellow.................................................................................................................................................................................79
Adobe Photoshop CS3JavaScript Scripting Reference 10
ColorSampler .................................................................................................................................................................................80Properties..................................................................................................................................................................................80
color....................................................................................................................................................................................80position .............................................................................................................................................................................80parent.................................................................................................................................................................................80typename .........................................................................................................................................................................80
Methods ....................................................................................................................................................................................80move...................................................................................................................................................................................80remove...............................................................................................................................................................................80
ColorSamplers ...............................................................................................................................................................................81Properties..................................................................................................................................................................................81
length.................................................................................................................................................................................81parent.................................................................................................................................................................................81typename .........................................................................................................................................................................81
Methods ....................................................................................................................................................................................81index...................................................................................................................................................................................81add ......................................................................................................................................................................................81getByName ......................................................................................................................................................................81removeAll .........................................................................................................................................................................81
ContactSheetOptions .................................................................................................................................................................82Properties..................................................................................................................................................................................82
acrossFirst.........................................................................................................................................................................82bestFit ................................................................................................................................................................................82caption...............................................................................................................................................................................82columnCount ..................................................................................................................................................................82flatten.................................................................................................................................................................................82font......................................................................................................................................................................................82fontSize..............................................................................................................................................................................82height.................................................................................................................................................................................82horizontal .........................................................................................................................................................................82mode ..................................................................................................................................................................................82resolution..........................................................................................................................................................................82rowCount..........................................................................................................................................................................82typename .........................................................................................................................................................................82useAutoSpacing.............................................................................................................................................................82vertical ...............................................................................................................................................................................83width ..................................................................................................................................................................................83
CountItem .......................................................................................................................................................................................84Properties..................................................................................................................................................................................84
position .............................................................................................................................................................................84parent.................................................................................................................................................................................84typename .........................................................................................................................................................................84
Methods ....................................................................................................................................................................................84remove...............................................................................................................................................................................84
CountItems .....................................................................................................................................................................................85Properties..................................................................................................................................................................................85
length.................................................................................................................................................................................85parent.................................................................................................................................................................................85typename .........................................................................................................................................................................85
Methods ....................................................................................................................................................................................85index...................................................................................................................................................................................85
Adobe Photoshop CS3JavaScript Scripting Reference 11
add ......................................................................................................................................................................................85getByName ......................................................................................................................................................................85removeAll .........................................................................................................................................................................85
DCS1_SaveOptions......................................................................................................................................................................86Properties..................................................................................................................................................................................86
dCS ......................................................................................................................................................................................86embedColorProfile........................................................................................................................................................86encoding...........................................................................................................................................................................86halftoneScreen ...............................................................................................................................................................86interpolation....................................................................................................................................................................86preview..............................................................................................................................................................................86transferFunction.............................................................................................................................................................86typename .........................................................................................................................................................................86vectorData........................................................................................................................................................................86
DCS2_SaveOptions......................................................................................................................................................................87Properties..................................................................................................................................................................................87
dCS ......................................................................................................................................................................................87embedColorProfile........................................................................................................................................................87encoding...........................................................................................................................................................................87halftoneScreen ...............................................................................................................................................................87interpolation....................................................................................................................................................................87multiFileDCS....................................................................................................................................................................87preview..............................................................................................................................................................................87spotColors ........................................................................................................................................................................87transferFunction.............................................................................................................................................................87typename .........................................................................................................................................................................87vectorData........................................................................................................................................................................87
DICOMOpenOptions ...................................................................................................................................................................88Properties..................................................................................................................................................................................88
anonymize........................................................................................................................................................................88columns.............................................................................................................................................................................88reverse ...............................................................................................................................................................................88rows ....................................................................................................................................................................................88showOverlays..................................................................................................................................................................88typename .........................................................................................................................................................................88windowLevel ...................................................................................................................................................................88windowWidth .................................................................................................................................................................88
Document .......................................................................................................................................................................................89Properties..................................................................................................................................................................................89
activeChannels ...............................................................................................................................................................89activeHistoryBrushSource ..........................................................................................................................................89activeHistoryState .........................................................................................................................................................89activeLayer .......................................................................................................................................................................89artLayers............................................................................................................................................................................89backgroundLayer...........................................................................................................................................................89bitsPerChannel ...............................................................................................................................................................89channels............................................................................................................................................................................89colorProfileName...........................................................................................................................................................89colorProfileType.............................................................................................................................................................89colorSamplers .................................................................................................................................................................90componentChannels....................................................................................................................................................90
Adobe Photoshop CS3JavaScript Scripting Reference 12
countItems .......................................................................................................................................................................90fullName............................................................................................................................................................................90height.................................................................................................................................................................................90histogram .........................................................................................................................................................................90historyStates....................................................................................................................................................................90info ......................................................................................................................................................................................90layerComps ......................................................................................................................................................................90layers ..................................................................................................................................................................................90layerSets............................................................................................................................................................................90managed...........................................................................................................................................................................90measurementScale .......................................................................................................................................................90mode ..................................................................................................................................................................................90name...................................................................................................................................................................................90parent.................................................................................................................................................................................91path.....................................................................................................................................................................................91pathItems .........................................................................................................................................................................91pixelAspectRatio ............................................................................................................................................................91quickMaskMode.............................................................................................................................................................91resolution..........................................................................................................................................................................91saved ..................................................................................................................................................................................91selection.......................................................................................................