JSON Action Manager

Description

“JSON Action Manager” is an open-source scripting library for Adobe Photoshop, written in JavaScript, and licensed using GPLv3. It allows developers to interact with the underlying Action Manager using a simpler JSON AM Data Format (please refer also to the JSON Project Introduction page to get more information).

What is called “JSON Action Manager” is basically a set of interrelated modules defining global variables acting as namespaces:

  • jamActions defines a set of functions related to decoding actions files into a format usable by scripts written with the scripting library engine.
  • jamBooks defines a set of color books-related functions for scripts written with the scripting library engine.
  • jamColors defines a set of color-related functions for scripts written with the scripting library engine.
  • jamEngine defines all the methods and properties of the scripting library engine.
  • jamHelpers defines a set of helper functions for scripts written with the scripting library engine.
  • jamJSON defines customized methods for translating a JavaScript data structure to and from a JSON text string; it can be used in scripts written with the scripting library engine, but also independently.
  • jamLayers defines a set of functions related to layers for scripts written with the scripting library engine.
  • jamShapes defines a set of functions related to decoding custom shapes files into a format usable by scripts written with the scripting library engine.
  • jamStyles defines a set of functions related to layer styles for scripts written with the scripting library engine.
  • jamText defines a set of functions related to layer text for scripts written with the scripting library engine.
  • jamUtils defines a set of utility functions for scripts written with the scripting library engine.

Note: the “Namespace” and “Syntax-highlighted file” HTML pages listed below are documentation files automatically generated from their respective source files, using a special comment syntax interpreted by jsdoc-toolkit.

Namespace Syntax-highlighted file Source file Minified source file
jamActions jamActions.jsxinc jamActions.jsxinc jamActions-min.jsxinc
jamBooks jamBooks.jsxinc jamBooks.jsxinc jamBooks-min.jsxinc
jamColors jamColors.jsxinc jamColors.jsxinc jamColors-min.jsxinc
jamEngine jamEngine.jsxinc jamEngine.jsxinc jamEngine-min.jsxinc
jamHelpers jamHelpers.jsxinc jamHelpers.jsxinc jamHelpers-min.jsxinc
jamJSON jamJSON.jsxinc jamJSON.jsxinc jamJSON-min.jsxinc
jamLayers jamLayers.jsxinc jamLayers.jsxinc jamLayers-min.jsxinc
jamShapes jamShapes.jsxinc jamShapes.jsxinc jamShapes-min.jsxinc
jamStyles jamStyles.jsxinc jamStyles.jsxinc jamStyles-min.jsxinc
jamText jamText.jsxinc jamText.jsxinc jamText-min.jsxinc
jamUtils jamUtils.jsxinc jamUtils.jsxinc jamUtils-min.jsxinc

Requirements

“JSON Action Manager” can be used from Adobe Photoshop CS or later. It has been successfully tested in CS and CS4 on Mac OS X, but should be platform agnostic.

Copyright

This Software is copyright © 2011-2016 by Michel MARIANI.

License

This Software is licensed under the GNU General Public License (GPL) v3.

Download

Installation

Download the Zip file and unzip it.

Move the JSON Action Manager folder to your user’s Home directory.

Start using the various functions of the library in your own scripts by inserting the following lines at the beginning of each script:

//@includepath "~/JSON Action Manager/"
//@include "jamEngine.jsxinc"

Depending on your needs, you may also want to add some of the following include statements:

//@include "jamActions.jsxinc"
//@include "jamBooks.jsxinc"
//@include "jamColors.jsxinc"
//@include "jamHelpers.jsxinc"
//@include "jamJSON.jsxinc"
//@include "jamLayers.jsxinc"
//@include "jamShapes.jsxinc"
//@include "jamStyles.jsxinc"
//@include "jamText.jsxinc"
//@include "jamUtils.jsxinc"

Alternatively, you can directly embed the contents of the compact one-line versions of the include files located in the minified subfolder. This is the way to go if you intend to produce stand-alone scripts, like the Utility Scripts or the Creative Scripts.

Version History

jamActions

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4

    • Normalized error messages.
  • 4.1

    • Simplified test in jamActions.isActionsPalette ().
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6

    • Incremented version number to keep in sync with other modules.
  • 3.5

    • Added jamActions.readActionDescriptor () to public functions, along with an extra insertVersionPrefix parameter.
  • 3.4

    • Incremented version number to keep in sync with other modules.
  • 3.3

    • Initial release.

jamBooks

  • 4.5.1

    • Added book description and simplified name of color components fields in function jamBooks.getColorBookFileColors ().
  • 4.5

    • Initial release.

jamColors

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4.5

    • Added handling of YCbCr, Lab and XYZ color models.
    • Removed constraining of component’s bounds in HCL color conversion functions.
    • Added named color Rebecca Purple introduced in CSS 4.
  • 4.4

    • Normalized error messages.
    • Added strict mode parameter to jamColors.nameToColor ().
    • Removed jamColors.w3cNameToRgb () and jamColors.x11NameToRgb (), replaced with jamColors.colorToRgb ().
  • 4.3.2

    • Removed rounding of components in color conversion functions.
  • 4.3.1

    • Added constraining of component’s bounds in color conversion functions.
    • Renamed HCL lightness to luminance.
  • 4.3

    • Initial release.

jamEngine

  • 4.5

    • Updated the disambiguating rules table: brush in brushPreset, currentToolOptions and displayPrefs classes.
  • 4.4.4

    • Added property jamEngine.displayDialogs (DialogModes.ERROR by default) used as default value for missing parameter displayDialogs when calling function jamEngine.jsonPlay ().
  • 4.4.1

    • Updated the disambiguating rules table: interpolation in dBrush and sampledBrush classes.
  • 4.4

    • Normalized error messages.
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6.4

    • Updated the disambiguating rules table: align in gradientLayer and patternLayer classes.
  • 3.6.3

    • Fixed reentrancy problem in jamEngine.simplifyObject () and jamEngine.simplifyList () by propagating hook function as parameter.
  • 3.6

    • Updated the disambiguating rules table: start in fileNamingRules class.
    • Added jamEngine.simplifyObject () and jamEngine.simplifyList ().
  • 3.5

    • Updated the disambiguating rules table for CS6: interpolation in transform event.
  • 3.4

    • Incremented version number to keep in sync with other modules.
  • 3.3

    • Updated the disambiguating rules table.
  • 3.2

    • Added support for large integers (from CS6).
  • 3.1

    • Removed hexadecimal string conversion for raw data format.
    • Moved jamEngine.dataToHexaString () and jamEngine.hexaToDataString () to jamUtils.dataToHexaString () and jamUtils.hexaToDataString ().
  • 3.0

    • Applied the redefined JSON AM Reference format.
  • 2.0

    • Renamed jamEngine.js to jamEngine.jsxinc.
    • Added alternative, more parse-friendly JSON compact syntax, using ordered pairs made of arrays instead of objects.
    • Modified the interface of jamEngine.getConflictingStringIdStrs (); now takes a CharID string as input and returns an array of the corresponding conflicting StringID strings if available, null otherwise.
    • Moved dataToHexaString () and hexaToDataString () to public members of jamEngine.
    • Changed names of members returned by jamEngine.eventIdAndActionDescriptorToJson (): “<event>”, “<descriptor>” and jamEngine.classIdAndActionDescriptorToJson (): “<class>”, “<descriptor>”.
    • Changed default names of members handled by jamEngine.compactToExplicit () and jamEngine.explicitToCompact (): “<type>”, “<value>”.
    • Simplified result of jamEngine.idToUniIdStrs () to a plain two-element array.
    • Merged specific and general context rules into one table with new format.
  • 1.0

    • Initial release.

jamHelpers

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4

    • Normalized error messages.
  • 4.3

    • Moved extra color-related functions to new jamColors module.
  • 4.2

    • Cleaned up code.
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6

    • Added support for explicit format as an alternative to existing minimal format for most important simplified formats.
    • Removed rounding of color component numerical values and transparency opacity in minimal format, for consistency with explicit format.
    • Removed jamHelpers.toChannelReference ().
    • Removed jamHelpers.hexToColor () and jamHelpers.colorToHex ().
    • Added jamHelpers.hexToColorObject () and jamHelpers.hexFromColorObject ().
    • Removed jamHelpers.namedColor ().
    • Added jamHelpers.nameToColorObject ().
    • Added jamHelpers.fromBlendRangeList ().
    • Added jamHelpers.fromCurvePointList ().
  • 3.5

    • Fixed simplified format for jamHelpers.toCurvePointList ().
    • Improved book color simplified format for jamHelpers.toColorObject () and jamHelpers.fromColorObject.
  • 3.4

    • Added jamHelpers.defineNamedColorsSet (), jamHelpers.enumerateNamedColors (), jamHelpers.namedColor (), jamHelpers.hexToColor () and jamHelpers.colorToHex ().
  • 3.3

    • Added links to respective simplified formats specification pages.
  • 3.2

    • Incremented version number to keep in sync with other modules.
  • 3.1

    • Incremented version number to keep in sync with other modules.
  • 3.0

    • Applied the redefined JSON AM Reference format.
  • 2.0

    • Renamed jamHelpers.js to jamHelpers.jsxinc.
    • Replaced all single color mode functions: jamHelpers.toBookColorObject (), etc. with jamHelpers.toColorObject ().
    • Added jamHelpers.fromColorObject ().
    • Added jamHelpers.toGradientObject () and jamHelpers.fromGradientObject ().
    • Renamed jamHelpers.toEnumChannelReference () to jamHelpers.toChannelReference ().
    • Revamped simplified format for jamHelpers.toCurvesAdjustmentList ().
    • Renamed jamHelpers.toHueSaturationAdjustmentList () to jamHelpers.toHueSatAdjustmentV2List ().
    • Removed jamHelpers.toHueSatMasterAdjustmentList (); jamHelpers.toHueSatAdjustmentV2List () should be used instead.
    • Revamped simplified format for jamHelpers.toBlendRangeList ().
    • Added jamHelpers.fromIntegerList ().
    • Revamped simplified format for jamHelpers.toPointObject ().
    • Added jamHelpers.toPointList ().
    • Revamped simplified format for jamHelpers.toOffsetObject ().
    • Revamped simplified format for jamHelpers.toRectangleObject ().
    • Removed jamHelpers.toRoundedRectangleObject (), merged into jamHelpers.toRectangleObject ().
    • Revamped simplified format for jamHelpers.toEllipseObject ().
    • Revamped simplified format for jamHelpers.toCustomShapeObject ().
    • Removed jamHelpers.toPointsPolygonObject (); jamHelpers.toPointList () should be used instead (cf. example).
    • Revamped simplified format for jamHelpers.toCurvePointList (); removed unused unit parameter too.
    • Revamped simplified format for jamHelpers.toRationalPointList ().
    • Revamped simplified format for jamHelpers.toPathComponentList ().
    • Added jamHelpers.fromPathComponentList ().
    • Moved jamHelpers.toDistanceUnit () and jamHelpers.fromDistanceUnit () to jamUtils.toDistanceUnit () and jamUtils.fromDistanceUnit ().
    • Removed jamHelpers.toHexaString () and jamHelpers.fromHexaString (); jamEngine.dataToHexaString () and jamEngine.hexaToDataString () should be used instead.
  • 1.0

    • Initial release.

jamJSON

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4

    • Normalized error messages.
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6

    • Incremented version number to keep in sync with other modules.
  • 3.5

    • Incremented version number to keep in sync with other modules.
  • 3.4

    • Incremented version number to keep in sync with other modules.
  • 3.3

    • Incremented version number to keep in sync with other modules.
  • 3.2

    • Incremented version number to keep in sync with other modules.
  • 3.1

    • Incremented version number to keep in sync with other modules.
  • 3.0

    • Incremented version number to keep in sync with other modules.
  • 2.0

    • Renamed jamJSON.js to jamJSON.jsxinc.
  • 1.0

    • Initial release.

jamLayers

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4.3

    • Fixed incorrect key in function toGradient (): “align” (not “alignment”).
  • 4.4

    • Normalized error messages.
  • 4.2

    • Cleaned up code.
  • 4.0

    • Removed reference to ‘this’ for main global object.
    • Improved handling of unsupported adjustment or fill layer type.
  • 3.6.7

    • Fixed type of pattern “phase” key (double instead of unit double).
  • 3.6.6

    • Improved handling of preset files: “using” key added to several adjustment layers: “blackAndWhite”, “channelMixer”, “curves”, “exposure”, “levels”, “selectiveColor”.
  • 3.6.5

    • Fixed bug in jamLayers.fromLayerObject (): “type” is now correctly handled in all cases.
  • 3.6.4

    • Initial release.

jamShapes

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4

    • Normalized error messages.
  • 4.1

    • Simplified test in jamShapes.isCustomShapesPrefsFile ().
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6

    • Incremented version number to keep in sync with other modules.
  • 3.5

    • Renamed field “id” to “ID” in data returned by dataFromCustomShapesFile ().
  • 3.4.3

    • Added parameter shapeIndex to dataFromCustomShapesFile ().
    • Renamed field “uuid” to “id” in data returned by dataFromCustomShapesFile ().
  • 3.4.2

    • Added global option: jamShapes.debugMode.
  • 3.4.1

    • Cleaned up some code.
  • 3.4

    • Initial release.

jamStyles

  • 4.5

    • Improved error handling.
  • 4.4.2

    • Added ignoreScale parameter to function jamStyles.setLayerStyle ().
    • Caught exception in function jamStyles.getLayerStyle () when it is not possible to apply styles/effects to a layer group (before Photoshop CS6).
  • 4.4

    • Normalized error messages.
  • 4.2

    • Cleaned up code.
    • Fixed bug in setLayerStyle (): in Photoshop CS, color space information returned by getDocumentMode () includes depth as well! For instance: “RGB48” instead of “RGBColor”.
  • 4.1

    • Simplified test in jamStyles.isStylesPalette ().
    • Replaced decodeURI () with File.decode () for the sake of consistency.
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6

    • Moved internal function simplifyObject () to public member of jamEngine.
    • Cleaned up code.
  • 3.5.4

    • Added undocumented parameter to jamStyles.getLayerStyle () to get actual patterns data as well.
    • Added functions jamStyles.patternsFromStylesFile () and jamStyles.patternsFileFromPatterns ().
    • Modified jamStyles.setApplicationGlobalAngle () and jamStyles.setDocumentGlobalAngle (): globalAltitude is now optional.
  • 3.5.3

    • Added handling of duotone document mode.
    • Fixed jamStyles.setLayerStyle (): the array “channelRestrictions” cannot be empty.
    • Added new functions: jamStyles.applyLayerStyle (), jamStyles.copyLayerStyle (), jamStyles.pasteLayerStyle (), jamStyles.scaleLayerEffects ().
    • Fixed jamStyles.setLayerStyle (): scaling must take into account the resolution of the document, to be consistent with the behavior of copyStyle () and pasteStyle ().
    • Added break statement in loop in getPresetStylesCount ().
    • Moved restored “chokeMatte” key to a value using percentUnit instead of pixelsUnit.
    • Normalized JSON AM data format for all calls to jamEngine.jsonPlay ().
  • 3.5.2

    • Modified descriptor restoring functions: unknown fields are now ignored.
    • Added new functions: jamStyles.removeAllLayerEffects (), jamStyles.removeLayerEffects (), jamStyles.removeLayerEffect (), jamStyles.showHideAllDocumentEffects (), jamStyles.showHideAllLayerEffects (), jamStyles.showHideLayerEffects (), jamStyles.showHideLayerEffect (), jamStyles.SetApplicationGlobalAngle (), jamStyles.SetDocumentGlobalAngle ().
  • 3.5.1

    • Modified jamStyles.setLayerStyle (): the effects property “scale” is taken into account.
    • Modified jamStyles.getLayerStyle (): the effects property “masterFXSwitch” is discarded, and a unique name is generated for each new temporary layer style.
    • Expanded jamHelpers.toChannelReference () inline to get rid of dependency.
    • Fixed a potential problem in jamStyles.dataFromStylesFile (): current values of jamEngine global options are now saved then restored after use.
    • Fixed imageModes array (5 and 6 are unsupported values).
  • 3.5

    • Initial release.

jamText

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4

    • Normalized error messages.
  • 4.2

    • Cleaned up code.
    • Fixed bug: missing break statement in jamText.toLayerTextObject ().
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6.3

    • Moved common graphics unit from layer text to path components level.
  • 3.6.2

    • Cleaned up code.
    • Added missing keys.
    • Updated examples.
  • 3.6.1

    • Initial release.

jamUtils

  • 4.5

    • Incremented version number to keep in sync with other modules.
  • 4.4

    • Normalized error messages.
  • 4.0

    • Removed reference to ‘this’ for main global object.
  • 3.6

    • Incremented version number to keep in sync with other modules.
  • 3.5

    • Added jamUtils.mergeData ().
  • 3.4

    • Added jamUtils.readTextFile () and jamUtils.writeTextFile (), now used by jamUtils.readJsonFile () and jamUtils.writeJsonFile () respectively.
    • Added optional lowercase parameter to jamUtils.dataToHexaString ().
  • 3.3.1

    • Added ‘TEXT’ Mac OS type to newly created JSON file in jamUtils.writeJsonFile ().
  • 3.3

    • Added jamUtils.loadActionSet ().
    • Added extra file.writeln () when needed in jamUtils.writeJsonFile ().
    • Added proper handling of null values in jamUtils.cloneData () and jamUtils.getCustomOptions ().
  • 3.2

    • Incremented version number to keep in sync with other modules.
  • 3.1

    • Moved jamEngine.dataToHexaString () and jamEngine.hexaToDataString () to jamUtils.dataToHexaString () and jamUtils.hexaToDataString ().
  • 3.0

    • Applied the redefined JSON AM Reference format.
  • 2.0

    • Initial release.

Tags: , , , , , , , , , , , , , , ,

Comments are closed.