Creating a New Photoshop Document
If you are new to scripting for Photoshop, please view our Photoshop Scripting Basics tutorial for an introduction to Photoshop scripting and a few exercises about basic JavaScript.
1. Because we need to set the units
(pixels, inches, mm, etc) when creating a new document, we need to store the old ruler unit settings
inside a variable and change it to the unit we want. For more information about ruler units, please
read the Setting
the Ruler and Type Units tutorial.
|
||
| |
||
2. After we've stored the old unit settings
and changed it to one of our own that will be used in this script, we can type in the script that'll
create a new document. The method we'll call to do this is the documents.add() command.
There are 6 optional parameters you can set inside the documents.add():
Type in the variable inside the documents.add() parenthesis in the order specified above.
Run the script inside Photoshop and it should create a new 800x600 pixels document inside Photoshop with the parameters set above. ![]() |
||
Tip:
To create a new document based on the specifications of an image inside a clipboard, don't enter any
parameters (ex. "documents.add();"). Photoshop will automatically enter the image specifications
from the image the user copied into the clipboard.
Closing a Photoshop Document
Closing the Photoshop document is simple with the document.close() method but you must tell Photoshop which active document to close first using the activeDocument property. The document.close() method works just like closing a document inside Photoshop using the File> Close menu. If the document was modified, it'll ask if the user wants to save, discard and close or cancel.
1. Begin by typing in the document.close()
method.
|
||
| |
||
2. Telling the script to close the current
active document is simple. Just replace "documents" with the activeDocument property.
|
||





More Tutorials:



