Edit in GitHubLog an issue

Photoshop

The top level application object, root of the Photoshop 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.

Properties

NameTypeAccessMin VersionDescription
actionTree
R
23.0
Returns the action tree shown in Actions panel, as an array of ActionSets, each containing Actions.
activeDocument
R W
23.0
The current document that has the application's focus.
backgroundColor
R W
23.0
The background color and color style for documents. (24.2)
currentTool
R
23.0
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
R W
23.0
The dialog mode for the application, which controls what types of dialogs should be displayed when your code is interacting with Photoshop.
documents
R
23.0
A list of the documents currently open.
fonts
R
23.0
The fonts installed on this system.
foregroundColor
R W
23.0
The foreground color (used to paint, fill, and stroke selections). (24.2)
preferences
R
24.0
Contains Photoshop preferences grouped into several categories similar to the Preferences dialog.
typename
string
R
23.0
The class name of the referenced object: "Photoshop".

Methods

batchPlay

23.0

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

NameType
commands
any
options
any

bringToFront

23.0

void

Brings application to focus, useful when your script ends, or requires an input.


convertUnits

23.4

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 clipboard
1// convert the current document's width to inches
2const exportDoc = psApp.activeDocument;
3let widthInInches = psApp.convertUnits(exportDoc.width,
4 Constants.Units.PIXELS,
5 Constant.Units.INCHES,
6 exportDoc.resolution);
7

Parameters

NameTypeDescription
fromValue
number
The value that is to be converted.
fromUnits
The unit that the fromValue is in. Use Constants.Units for valid values.
toUnits
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

23.0

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.

Copied to your clipboard
1// "Default Photoshop Size" 7x5 inches at 300ppi
2let newDoc1 = await app.createDocument();
3let newDoc2 = await app.createDocument({
4 width: 800,
5 height: 600,
6 resolution: 300,
7 mode: "RGBColorMode",
8 fill: "transparent"
9});
10let newDoc3 = await app.createDocument({preset: "My Default Size 1"});

Parameters

NameTypeDescription
options?
@DocumentCreateOptions

getColorProfiles

24.1

string[]

List of installed color profiles, for RGB and Gray modes.

Parameters

NameTypeDefault valueDescription
colorMode
string
'RGB'
Specify which color mode's profiles to list. (default: "RGB", options: "Gray")

open

23.0

async : Promise<Document>

Opens the specified document and returns the model

*Note that this API requires a UXPFileEntry object as its argument.

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

23.0

Promise<void>

Shows an alert in Photoshop with the given message.

Parameters

NameType
message
string
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.