adobe photoshop cs5 javascript reference · adobe photoshop cs5 javascript scripting reference 15...

of 233/233
bc ADOBE PHOTOSHOP CS5 JAVASCRIPT SCRIPTING REFERENCE Revision 1

Post on 19-Sep-2018

218 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • bbc

    ADOBE PHOTOSHOP CS5

    JAVASCRIPT SCRIPTING REFERENCERevision 1

  • 2010 Adobe Systems Incorporated. All rights reserved.

    Adobe Creative Suite 5 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 ............................................................................................................................... 33JavaScript support in Adobe Photoshop CS5 ....................................................................................................................33

    Executing scripts ....................................................................................................................................................................34Installing scripts ...............................................................................................................................................................34Executing other scripts ..................................................................................................................................................34

    Startup scripts .........................................................................................................................................................................34Object model usage and naming...........................................................................................................................................35Changes since earlier versionsCS5 changes ..................................................................................................................35.............................................................................................................................................................................................................36

    2 JavaScript Object Reference ..................................................................................................... 37Object descriptions......................................................................................................................................................................37

    Properties notation ...............................................................................................................................................................37displayDialogs.................................................................................................................................................................37

    Methods notation ..................................................................................................................................................................37crop.....................................................................................................................................................................................38

    ActionDescriptor ..........................................................................................................................................................................39Properties..................................................................................................................................................................................39

    count ..................................................................................................................................................................................39typename .........................................................................................................................................................................39

    Methods ....................................................................................................................................................................................39clear ....................................................................................................................................................................................39erase ...................................................................................................................................................................................39fromStream......................................................................................................................................................................39getBoolean.......................................................................................................................................................................39getClass .............................................................................................................................................................................39getData..............................................................................................................................................................................39getDouble ........................................................................................................................................................................39getEnumerationType ...................................................................................................................................................39getEnumerationValue..................................................................................................................................................39getInteger.........................................................................................................................................................................39getKey................................................................................................................................................................................39getList ................................................................................................................................................................................40getObjectType................................................................................................................................................................40getObjectValue...............................................................................................................................................................40getPath ..............................................................................................................................................................................40getReference ...................................................................................................................................................................40getString ...........................................................................................................................................................................40getType .............................................................................................................................................................................40getUnitDoubleType......................................................................................................................................................40getUnitDoubleValue.....................................................................................................................................................40hasKey................................................................................................................................................................................40isEqual................................................................................................................................................................................40putBoolean ......................................................................................................................................................................40putClass.............................................................................................................................................................................40putData .............................................................................................................................................................................40

  • Adobe Photoshop CS5JavaScript Scripting Reference 4

    putDouble ........................................................................................................................................................................40putEnumerated ..............................................................................................................................................................40putInteger ........................................................................................................................................................................40putList ................................................................................................................................................................................41putObject..........................................................................................................................................................................41putPath..............................................................................................................................................................................41putReference...................................................................................................................................................................41putString...........................................................................................................................................................................41putUnitDouble................................................................................................................................................................41toStream ...........................................................................................................................................................................41

    ActionList.........................................................................................................................................................................................42Properties..................................................................................................................................................................................42

    count ..................................................................................................................................................................................42typename .........................................................................................................................................................................42

    Methods ....................................................................................................................................................................................42clear ....................................................................................................................................................................................42getBoolean.......................................................................................................................................................................42getClass .............................................................................................................................................................................42getData..............................................................................................................................................................................42getDouble ........................................................................................................................................................................42getEnumerationType ...................................................................................................................................................42getEnumerationValue..................................................................................................................................................42getInteger.........................................................................................................................................................................42getList ................................................................................................................................................................................43getObjectType................................................................................................................................................................43getObjectValue...............................................................................................................................................................43getPath ..............................................................................................................................................................................43getReference ...................................................................................................................................................................43getString ...........................................................................................................................................................................43getType .............................................................................................................................................................................43getUnitDoubleType......................................................................................................................................................43getUnitDoubleValue.....................................................................................................................................................43putBoolean ......................................................................................................................................................................43putClass.............................................................................................................................................................................43putData .............................................................................................................................................................................43putDouble ........................................................................................................................................................................43putEnumerated ..............................................................................................................................................................43putInteger ........................................................................................................................................................................43putList ................................................................................................................................................................................43putObject..........................................................................................................................................................................43putPath..............................................................................................................................................................................43putReference...................................................................................................................................................................43putString...........................................................................................................................................................................44putUnitDouble................................................................................................................................................................44

    ActionReference ...........................................................................................................................................................................45Properties..................................................................................................................................................................................45

    typename .........................................................................................................................................................................45Methods ....................................................................................................................................................................................45

    getContainer ...................................................................................................................................................................45getDesiredClass..............................................................................................................................................................45getEnumeratedType.....................................................................................................................................................45

  • Adobe Photoshop CS5JavaScript Scripting Reference 5

    getEnumeratedValue ...................................................................................................................................................45getForm.............................................................................................................................................................................45getIdentifier .....................................................................................................................................................................45getIndex............................................................................................................................................................................45getName ...........................................................................................................................................................................45getOffset ...........................................................................................................................................................................45getProperty......................................................................................................................................................................45putClass.............................................................................................................................................................................46putEnumerated ..............................................................................................................................................................46putIdentifier.....................................................................................................................................................................46putIndex............................................................................................................................................................................46putName...........................................................................................................................................................................46putOffset...........................................................................................................................................................................46putProperty......................................................................................................................................................................46

    Application .....................................................................................................................................................................................47Properties..................................................................................................................................................................................47

    activeDocument.............................................................................................................................................................47backgroundColor...........................................................................................................................................................47build....................................................................................................................................................................................47colorSettings ...................................................................................................................................................................47displayDialogs.................................................................................................................................................................47documents .......................................................................................................................................................................47fonts....................................................................................................................................................................................47foregroundColor ............................................................................................................................................................47freeMemory .....................................................................................................................................................................47locale ..................................................................................................................................................................................48macintoshFileTypes......................................................................................................................................................48measurementLog ..........................................................................................................................................................48name...................................................................................................................................................................................48notifiers .............................................................................................................................................................................48notifiersEnabled.............................................................................................................................................................48path.....................................................................................................................................................................................48playbackDisplayDialogs ..............................................................................................................................................48playbackParameters .....................................................................................................................................................48preferences ......................................................................................................................................................................48preferencesFolder .........................................................................................................................................................48recentFiles ........................................................................................................................................................................48scriptingBuildDate ........................................................................................................................................................48scriptingVersion .............................................................................................................................................................48systemInformation........................................................................................................................................................48typename .........................................................................................................................................................................48version ...............................................................................................................................................................................49windowsFileTypes.........................................................................................................................................................49

    Methods ....................................................................................................................................................................................49batch ..................................................................................................................................................................................49beep....................................................................................................................................................................................49bringToFront ...................................................................................................................................................................49charIDToTypeID..............................................................................................................................................................49doAction ...........................................................................................................................................................................49eraseCustomOptions....................................................................................................................................................49executeAction.................................................................................................................................................................49

  • Adobe Photoshop CS5JavaScript Scripting Reference 6

    executeActionGet..........................................................................................................................................................49featureEnabled ...............................................................................................................................................................49getCustomOptions........................................................................................................................................................50isQuicktimeAvailable....................................................................................................................................................50load .....................................................................................................................................................................................50makeContactSheet........................................................................................................................................................50makePDFPresentation .................................................................................................................................................50makePhotoGallery.........................................................................................................................................................50makePhotomerge..........................................................................................................................................................50makePicturePackage....................................................................................................................................................50open ...................................................................................................................................................................................51openDialog ......................................................................................................................................................................51purge..................................................................................................................................................................................51putCustomOptions .......................................................................................................................................................51refresh................................................................................................................................................................................51refreshFonts.....................................................................................................................................................................51runMenuItem ..................................................................................................................................................................51showColorPicker ............................................................................................................................................................52stringIDToTypeID...........................................................................................................................................................52togglePalettes.................................................................................................................................................................52typeIDToCharID..............................................................................................................................................................52typeIDToStringID ...........................................................................................................................................................52

    ArtLayer............................................................................................................................................................................................55Properties..................................................................................................................................................................................55

    allLocked...........................................................................................................................................................................55blendMode.......................................................................................................................................................................55bounds...............................................................................................................................................................................55fillOpacity..........................................................................................................................................................................55filterMaskDensity ...........................................................................................................................................................55filterMaskFeather...........................................................................................................................................................55grouped ............................................................................................................................................................................55isBackgroundLayer........................................................................................................................................................55kind .....................................................................................................................................................................................55layerMaskDensity...........................................................................................................................................................55layerMaskFeather ..........................................................................................................................................................56linkedLayers.....................................................................................................................................................................56name...................................................................................................................................................................................56opacity ...............................................................................................................................................................................56parent.................................................................................................................................................................................56pixelsLocked....................................................................................................................................................................56positionLocked...............................................................................................................................................................56textItem.............................................................................................................................................................................56transparentPixelsLocked.............................................................................................................................................56typename .........................................................................................................................................................................56vectorMaskDensity........................................................................................................................................................56vectorMaskFeather .......................................................................................................................................................56visible .................................................................................................................................................................................56xmpMetadata..................................................................................................................................................................56

    Methods ....................................................................................................................................................................................57adjustBrightnessContrast ...........................................................................................................................................57adjustColorBalance .......................................................................................................................................................57

  • Adobe Photoshop CS5JavaScript Scripting Reference 7

    adjustCurves....................................................................................................................................................................57adjustLevels .....................................................................................................................................................................57applyAddNoise ...............................................................................................................................................................57applyAverage..................................................................................................................................................................57applyBlur...........................................................................................................................................................................57applyBlurMore ................................................................................................................................................................57applyClouds.....................................................................................................................................................................57applyCustomFilter.........................................................................................................................................................57applyDeInterlace............................................................................................................................................................58applyDespeckle ..............................................................................................................................................................58applyDifferenceClouds................................................................................................................................................58applyDiffuseGlow ..........................................................................................................................................................58applyDisplace..................................................................................................................................................................58applyDustAndScratches..............................................................................................................................................58applyGaussianBlur.........................................................................................................................................................58applyGlassEffect.............................................................................................................................................................58applyHighPass ................................................................................................................................................................58applyLensBlur .................................................................................................................................................................59applyLensFlare................................................................................................................................................................59applyMaximum ..............................................................................................................................................................59applyMedianNoise ........................................................................................................................................................59applyMinimum ...............................................................................................................................................................60applyMotionBlur ............................................................................................................................................................60applyNTSC........................................................................................................................................................................60applyOceanRipple .........................................................................................................................................................60applyOffset.......................................................................................................................................................................60applyPinch .......................................................................................................................................................................60applyPolarCoordinates ................................................................................................................................................60applyRadialBlur ..............................................................................................................................................................60applyRipple......................................................................................................................................................................60applySharpen..................................................................................................................................................................60applySharpenEdges......................................................................................................................................................60applySharpenMore .......................................................................................................................................................60applyShear .......................................................................................................................................................................60applySmartBlur...............................................................................................................................................................61applySpherize .................................................................................................................................................................61applyStyle.........................................................................................................................................................................61applyTextureFill..............................................................................................................................................................61applyTwirl .........................................................................................................................................................................61applyUnSharpMask.......................................................................................................................................................61applyWave........................................................................................................................................................................61applyZigZag.....................................................................................................................................................................61autoContrast....................................................................................................................................................................61autoLevels ........................................................................................................................................................................61clear ....................................................................................................................................................................................61copy ....................................................................................................................................................................................62cut........................................................................................................................................................................................62desaturate ........................................................................................................................................................................62duplicate ...........................................................................................................................................................................62equalize .............................................................................................................................................................................62invert ..................................................................................................................................................................................62

  • Adobe Photoshop CS5JavaScript Scripting Reference 8

    link.......................................................................................................................................................................................62merge.................................................................................................................................................................................62mixChannels....................................................................................................................................................................63move...................................................................................................................................................................................63photoFilter .......................................................................................................................................................................63posterize ...........................................................................................................................................................................63rasterize.............................................................................................................................................................................63remove...............................................................................................................................................................................63resize ..................................................................................................................................................................................64rotate..................................................................................................................................................................................64selectiveColor..................................................................................................................................................................64shadowHighlight ...........................................................................................................................................................64threshold...........................................................................................................................................................................64translate ............................................................................................................................................................................64unlink .................................................................................................................................................................................64

    ArtLayers..........................................................................................................................................................................................67Properties..................................................................................................................................................................................67

    length.................................................................................................................................................................................67parent.................................................................................................................................................................................67typename .........................................................................................................................................................................67

    Methods ....................................................................................................................................................................................67add ......................................................................................................................................................................................67getByName ......................................................................................................................................................................67removeAll .........................................................................................................................................................................67

    BatchOptions .................................................................................................................................................................................68Properties..................................................................................................................................................................................68

    destination .......................................................................................................................................................................68destinationFolder ..........................................................................................................................................................68errorFile .............................................................................................................................................................................68fileNaming........................................................................................................................................................................68macintoshCompatible .................................................................................................................................................68overrideOpen..................................................................................................................................................................68overrideSave....................................................................................................................................................................68startingSerial ...................................................................................................................................................................68suppressOpen.................................................................................................................................................................68suppressProfile ...............................................................................................................................................................69typename .........................................................................................................................................................................69unixCompatible..............................................................................................................................................................69windowsCompatible ....................................................................................................................................................69

    BitmapConversionOptions .......................................................................................................................................................70Properties..................................................................................................................................................................................70

    angle...................................................................................................................................................................................70frequency..........................................................................................................................................................................70method..............................................................................................................................................................................70patternName...................................................................................................................................................................70resolution..........................................................................................................................................................................70shape..................................................................................................................................................................................70typename .........................................................................................................................................................................70

    BMPSaveOptions ..........................................................................................................................................................................71Properties..................................................................................................................................................................................71

    alphaChannels ................................................................................................................................................................71

  • Adobe Photoshop CS5JavaScript Scripting Reference 9

    depth..................................................................................................................................................................................71flipRowOrder ...................................................................................................................................................................71osType................................................................................................................................................................................71rleCompression ..............................................................................................................................................................71typename .........................................................................................................................................................................71

    CameraRAWOpenOptions ........................................................................................................................................................72Properties..................................................................................................................................................................................72

    bitsPerChannel ...............................................................................................................................................................72blueHue.............................................................................................................................................................................72blueSaturation ................................................................................................................................................................72brightness.........................................................................................................................................................................72chromaticAberrationBY...............................................................................................................................................72chromaticAberrationRC...............................................................................................................................................72colorNoiseReduction....................................................................................................................................................72colorSpace........................................................................................................................................................................72contrast .............................................................................................................................................................................72exposure ...........................................................................................................................................................................72greenHue..........................................................................................................................................................................72greenSaturation .............................................................................................................................................................72luminanceSmoothing ..................................................................................................................................................72redHue...............................................................................................................................................................................72redSaturation ..................................................................................................................................................................72resolution..........................................................................................................................................................................72saturation .........................................................................................................................................................................72settings..............................................................................................................................................................................72shadows ............................................................................................................................................................................72shadowTint ......................................................................................................................................................................72sharpness..........................................................................................................................................................................72size ......................................................................................................................................................................................72temperature.....................................................................................................................................................................72tint.......................................................................................................................................................................................73typename .........................................................................................................................................................................73vignettingAmount ........................................................................................................................................................73vignettingMidpoint ......................................................................................................................................................73whiteBalance...................................................................................................................................................................73

    Channel ............................................................................................................................................................................................74Properties..................................................................................................................................................................................74

    color....................................................................................................................................................................................74histogram .........................................................................................................................................................................74kind .....................................................................................................................................................................................74name...................................................................................................................................................................................74opacity ...............................................................................................................................................................................74parent.................................................................................................................................................................................74typename .........................................................................................................................................................................74visible .................................................................................................................................................................................74

    Methods ....................................................................................................................................................................................74duplicate ...........................................................................................................................................................................74merge.................................................................................................................................................................................75remove...............................................................................................................................................................................75

    Channels ..........................................................................................................................................................................................76Properties..................................................................................................................................................................................76

  • Adobe Photoshop CS5JavaScript Scripting Reference 10

    length.................................................................................................................................................................................76parent.................................................................................................................................................................................76typename .........................................................................................................................................................................76

    Methods ....................................................................................................................................................................................76add ......................................................................................................................................................................................76getByName ......................................................................................................................................................................76removeAll .........................................................................................................................................................................76

    CMYKColor......................................................................................................................................................................................81Properties..................................................................................................................................................................................81

    black ...................................................................................................................................................................................81cyan.....................................................................................................................................................................................81magenta............................................................................................................................................................................81typename .........................................................................................................................................................................81yellow.................................................................................................................................................................................81

    ColorSampler .................................................................................................................................................................................82Properties..................................................................................................................................................................................82

    color....................................................................................................................................................................................82position .............................................................................................................................................................................82parent.................................................................................................................................................................................82typename .........................................................................................................................................................................82

    Methods ....................................................................................................................................................................................82move...................................................................................................................................................................................82remove...............................................................................................................................................................................82

    ColorSamplers ...............................................................................................................................................................................83Properties..................................................................................................................................................................................83

    length.................................................................................................................................................................................83parent.................................................................................................................................................................................83typename .........................................................................................................................................................................83

    Methods ....................................................................................................................................................................................83add ......................................................................................................................................................................................83removeAll .........................................................................................................................................................................83

    ContactSheetOptions .................................................................................................................................................................84Properties..................................................................................................................................................................................84

    acrossFirst.........................................................................................................................................................................84bestFit ................................................................................................................................................................................84caption...............................................................................................................................................................................84columnCount ..................................................................................................................................................................84flatten.................................................................................................................................................................................84font......................................................................................................................................................................................84fontSize..............................................................................................................................................................................84height.................................................................................................................................................................................84horizontal .........................................................................................................................................................................84mode ..................................................................................................................................................................................84resolution..........................................................................................................................................................................84rowCount..........................................................................................................................................................................84typename .........................................................................................................................................................................84useAutoSpacing.............................................................................................................................................................84vertical ...............................................................................................................................................................................84width ..................................................................................................................................................................................84

    CountItem .......................................................................................................................................................................................85Properties..................................................................................................................................................................................85

  • Adobe Photoshop CS5JavaScript Scripting Reference 11

    position .............................................................................................................................................................................85parent.................................................................................................................................................................................85typename .........................................................................................................................................................................85

    Methods ....................................................................................................................................................................................85remove...............................................................................................................................................................................85

    CountItems .....................................................................................................................................................................................86Properties..................................................................................................................................................................................86

    length.................................................................................................................................................................................86parent.................................................................................................................................................................................86typename .........................................................................................................................................................................86

    Methods ....................................................................................................................................................................................86add ......................................................................................................................................................................................86getByName ......................................................................................................................................................................86removeAll .........................................................................................................................................................................86

    DCS1_SaveOptions......................................................................................................................................................................87Properties..................................................................................................................................................................................87

    dCS ......................................................................................................................................................................................87embedColorProfile........................................................................................................................................................87encoding...........................................................................................................................................................................87halftoneScreen ...............................................................................................................................................................87interpolation....................................................................................................................................................................87preview..............................................................................................................................................................................87transferFunction.............................................................................................................................................................87typename .........................................................................................................................................................................87vectorData........................................................................................................................................................................87

    DCS2_SaveOptions......................................................................................................................................................................88Properties..................................................................................................................................................................................88

    dCS ......................................................................................................................................................................................88embedColorProfile........................................................................................................................................................88encoding...........................................................................................................................................................................88halftoneScreen ...............................................................................................................................................................88interpolation....................................................................................................................................................................88multiFileDCS....................................................................................................................................................................88preview..............................................................................................................................................................................88spotColors ........................................................................................................................................................................88transferFunction.............................................................................................................................................................88typename .........................................................................................................................................................................88vectorData........................................................................................................................................................................88

    DICOMOpenOptions ...................................................................................................................................................................89Properties..................................................................................................................................................................................89

    anonymize........................................................................................................................................................................89columns.............................................................................................................................................................................89reverse ...............................................................................................................................................................................89rows ....................................................................................................................................................................................89showOverlays..................................................................................................................................................................89typename .........................................................................................................................................................................89windowLevel ...................................................................................................................................................................89windowWidth .................................................................................................................................................................89

    Document .......................................................................................................................................................................................90Properties..................................................................................................................................................................................90

    activeChannels ...............................................................................................................................................................90

  • Adobe Photoshop CS5JavaScript Scripting Reference 12

    activeHistoryBrushSource ..........................................................................................................................................90activeHistoryState .........................................................................................................................................................90activeLayer .......................................................................................................................................................................90artLayers............................................................................................................................................................................90backgroundLayer...........................................................................................................................................................90bitsPerChannel ...............................................................................................................................................................90channels............................................................................................................................................................................90colorProfileName...........................................................................................................................................................90colorProfileType.............................................................................................................................................................90colorSamplers .................................................................................................................................................................90componentChannels....................................................................................................................................................90countItems .......................................................................................................................................................................91fullName............................................................................................................................................................................91guides ................................................................................................................................................................................91height.................................................................................................................................................................................91histogram .........................................................................................................................................................................91historyStates....................................................................................................................................................................91info ......................................................................................................................................................................................91layerComps ......................................................................................................................................................................91layers ..................................................................................................................................................................................91layerSets............................................................................................................................................................................91managed...............................................