Photoshop App
The top level application object, root of our 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.
Accessors
actionTree
• get actionTree(): ActionSet[]
Returns the action tree shown in Actions panel, as an array of ActionSets, each containing actions
activeDocument
• get activeDocument(): Document
The current active document
Copied to your clipboardconst doc = Photoshop.activeDocument;
• set activeDocument(doc: Document): void
Set the current active document to be given one
Copied to your clipboardconst doc = Photoshop.activeDocument;
Parameters:
| Name | Type |
|---|---|
doc |
backgroundColor
• get backgroundColor(): Color
The default background color and color style for documents.
currentTool
• get currentTool(): Tool
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
documents
• get documents(): Document[]
List of currently open documents
Copied to your clipboardconst documents = app.documents;
eventNotifier
• set eventNotifier(handler: function): void
Dev environments only.
A callback for event notifications in Photoshop. This will cause your plugin to get a notification on every event the user is doing, so it may slow things down. But it will be helpful to figure out different descriptors
Copied to your clipboardapp.eventNotifier = (event, descriptor) => {console.log(event, JSON.stringify(descriptor, null, ' '));}
This is temporary while we are in Alpha, we are working on a more structured notification system This setter will not function outside developer mode
To register listeners to specific events in production, follow Event Listeners in the Advanced section.
Parameters:
▪ handler: function
▸ (event: string, descriptor: object): void
Parameters:
| Name | Type |
|---|---|
event | string |
descriptor | object |
foregroundColor
• get foregroundColor(): Color
The default foreground color (used to paint, fill, and stroke selections)
Methods
batchPlay
▸ batchPlay(commands: any, options: any): Promise‹Descriptor[]›
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. Learn more in our batchPlay reference.
Parameters:
| Name | Type |
|---|---|
commands | any |
options | any |
bringToFront
▸ bringToFront(): void
Brings application to focus, useful when your script ends, or requires an input
createDocument
▸ createDocument(options?: DocumentCreateOptions): Promise‹Document | null›
Create a new document. See @DocumentCreateOptions.
Documents not created from presets must specify width, height, resolution, (color) mode, and fill.
Copied to your clipboardlet newDoc1 = app.createDocument(); // creates a 2100px * 1500px documentlet newDoc2 = app.createDocument({width: 800, height: 600, resolution: 300, mode: "RGBColorMode", fill: "transparent"});let newDoc3 = app.createDocument({preset: "My Default Size 1"});
Parameters:
| Name | Type |
|---|---|
options? | DocumentCreateOptions |
open
▸ open(entry?: File): Promise‹Document›
Opens the specified document and returns it's model
(0.4.0) Please note that this API now requires you to provide a UXPFileEntry
async
Copied to your clipboard// Open a file given entrylet entry = await require('uxp').storage.localFileSystem.getFileForOpening()const document = await app.open(entry);// Show open file dialogconst document = await app.open();
Parameters:
| Name | Type |
|---|---|
entry? | File |
showAlert
▸ showAlert(message: string): Promise‹void›
Shows an alert in Photoshop with the given message
Parameters:
| Name | Type |
|---|---|
message | string |
