Samantha Makes
Photoshop Scripts – Automate your work – Part II – Creating  a new document

Photoshop Scripts – Automate your work – Part II – Creating a new document

In the second part of this series, I am going to walk you through creating a new document with a specific set of dimensions. While you can quickly create a new document in photoshop without a script, this will work as a building block for what we will do later. Here is what we are […]

In the second part of this series, I am going to walk you through creating a new document with a specific set of dimensions. While you can quickly create a new document in photoshop without a script, this will work as a building block for what we will do later.

Here is what we are writing:

Code for new document

This time, we have three prompts: width, height, and name. We could add more prompts, but I am keeping some things default in this case.

  • The new documents created in this script will always have dimensions in pixels
  • We will always use the default RGB mode
  • And we will always use 300 dpi

Of course, feel free to customize more, with more prompts. 🙂

Here is the breakdown:

app – this is photoshop – it an object (in programmer speak) that has some properties and methods.

documents – this is a property of the photoshop object. It also has a series of methods and properties.

add – This is the method that we can call on the documents to ADD a new document. For this method to work, you need to tell it specifics about the new document you want to create, like width, height, resolution, name, and color mode.

You can see that for width and height I am not passing a number, but another object. This object is called UnitValue and it is composed of a value and the unit. In our case, unit is always ‘PX’. But we could pass ‘IN’ or ‘CM’. If we were to resize an object, we could pass UnitValue with a unit of ‘PERCENT’.

TIP

If you want to find out more about the methods and objects available for Photoshop, check out: https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-javascript-ref-2020.pdf

To see this in action, you need to save this file using a JSX extension in the following folder: /Applications/Adobe Photoshop 2021/Presets/Scripts/<Create a folder for your scripts>/ – I called my file NewDocument.jsx

Script running

Congratulations – You told Photoshop how to create a new document! Next we are going to see how you can create a pattern in photoshop.