Edit in GitHubLog an issue

Photoshop App

The top level application object, root of our DOM

Copied to your clipboard
const 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 clipboard
const doc = Photoshop.activeDocument;

set activeDocument(doc: Document): void

Set the current active document to be given one

Copied to your clipboard
const doc = Photoshop.activeDocument;

Parameters:

NameType
docDocument

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 clipboard
const 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 clipboard
1app.eventNotifier = (event, descriptor) => {
2 console.log(event, JSON.stringify(descriptor, null, ' '));
3}

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:

NameType
eventstring
descriptorobject

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:

NameType
commandsany
optionsany

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 clipboard
1let newDoc1 = app.createDocument(); // creates a 2100px * 1500px document
2let newDoc2 = app.createDocument({width: 800, height: 600, resolution: 300, mode: "RGBColorMode", fill: "transparent"});
3let newDoc3 = app.createDocument({preset: "My Default Size 1"});

Parameters:

NameType
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
1// Open a file given entry
2let entry = await require('uxp').storage.localFileSystem.getFileForOpening()
3const document = await app.open(entry);
4
5// Show open file dialog
6const document = await app.open();

Parameters:

NameType
entry?File

showAlert#

showAlert(message: string): Promise‹void›

Shows an alert in Photoshop with the given message

Parameters:

NameType
messagestring
Copyright © 2021 Adobe. All rights reserved.