Photoshop
The top level application object, root of the Photoshop DOM
Copied to your clipboardconst app = require('photoshop').app
From here you can access open documents, tools, UI elements and run commands or menu items.
Properties#
Name | Type | Access | Description |
---|---|---|---|
actionTree | ActionSet[] | Read-only | Returns the action tree shown in Actions panel, as an array of ActionSets, each containing actions |
activeDocument | Document | Read-write | The current active document |
backgroundColor | SolidColor | Read-only | The default background color and color style for documents. |
currentTool | Tool | Read-only | Current selected tool. For now, the Tool class is an object with only an `id` field. In the future, we aim to provide tools with their own classes |
displayDialogs | DialogModes | Read-write | The dialog mode for the application, which controls what types of dialogs should be displayed when your plugin is interacting with Photoshop. |
documents | Documents | Read-only | A list of the documents currently open |
fonts | TextFonts | Read-only | The fonts installed on this system. |
foregroundColor | SolidColor | Read-write | The default foreground color (used to paint, fill, and stroke selections) |
typename | string | Read-only | The class name of the referenced Photoshop object |
Methods#
batchPlay#
Promise<ActionDescriptor[]>
At the heart of all our APIs is batchPlay. It is the evolution of executeAction. It accepts ActionDescriptors deserialized from JS objects, and can play multiple descriptors sequentially without updating the UI. This API is subject to change and may be accessible in other ways in the future.
Parameters#
Name | Type |
---|---|
commands | any |
options | any |
bringToFront#
void
Brings application to focus, useful when your script ends, or requires an input
convertUnits#
number
Convert the given value from one unit to another. Available units are: Constants.Units.{CM, MM, INCHES, PIXELS, POINTS, PICAS}. Use Document.resolution when converting from or to PIXELS. For example, use this routine for converting a document's width from pixels to inches.
Copied to your clipboard1// convert the current document's width to inches2const exportDoc = psApp.activeDocument;3let widthInInches = psApp.convertUnits(exportDoc.width,4 Constants.Units.PIXELS,5 Constant.Units.INCHES,6 exportDoc.resolution);7
Parameters#
Name | Type | Description |
---|---|---|
fromValue | number | The value that is to be converted. |
fromUnits | Units | The unit that the fromValue is in. Use Constants.Units for valid values. |
toUnits | Units | The unit that the return value is in. Use Constants.Units for valid values. |
resolution? | number | The pixels per inch value to use when converting to and from pixel values. |
createDocument#
async : Promise<Document>
Create a new document.
No options will create a document of 7 x 5 inches at 300 pixels per inch. This is the same as the "Default Photoshop Size" preset.
An object with a 'preset' string parameter can be used to specify any of the other presets that come installed with Photoshop or created by users.
An object with one or more parameters can also be supplied. Any parameter missing will be set to the default of: width 2100 pixels, height 1500 pixels, resolution 300 pixels per inch, mode: @RGBColorMode and a fill of white with no transparency.
Parameters#
Name | Type | Description |
---|---|---|
options? | DocumentCreateOptions | @DocumentCreateOptions |
open#
async : Promise<Document>
Opens the specified document and returns the model
(0.4.0) Please note that this API now requires you to provide a UXPFileEntry
Parameters#
Name | Type |
---|---|
entry? | File |
showAlert#
Promise<void>
Shows an alert in Photoshop with the given message
Parameters#
Name | Type |
---|---|
message | string |