Create your 1st Script with explanations
**Create new document in Photoshop steps:
- Click File → New
- Enter 500px in width and height
- Hit “Create”
The same process with a script would look like this:
- Call the application: app
- For document create: Documents
In JavaScript, we can use the add() method only with the collection name. The add() method is not valid with objects other than collection objects.
We must use the collection name, which a plural form of the object name, as follows:
app.documents.add() (not use app.document.add())
- Call the function to add sizes, resolution & title: add(width, height, Resolution, “document name”)
And the code would look like this:
app.documents.add(100, 50, 72, "helloPhotoshop");
Explanation is below:
Some few lines of code change from different versions of Photoshop; the one minor thing that CS users must add is ‘app’ in front of everything that relates to the document/photoshop application in general. As an example, instead of documents.add(), CS users must add ‘app.documents.add(), and instead of ‘documents’ or ‘activeDocument’ must add ‘app.documents’ and ‘app.activeDocument’.
** Set the Ruler Unit in Photoshop steps:
- Click File → Edit >Preferences > Units & Rulers (CTRL+K)
- Set the Units Section Rulers (7 ruler) to Inches (Pixels, Inches, Centimeters, Millimeters, Points, Picas (1 pica = 12 points), Percent)
- Hit “OK”
The same process with a script would look like this:
- Call the application: app
- For Preferences Setting: Preferences
- Call the function to ruler units: rulerUnits
- Call the function to change units: INCHES
- There are 7 Units must use Capital Letter (PIXELS, INCHES, CENTIMETERS, MILLIMETERS, POINTS, PICAS (1 PICA = 12 POINTS), PERCENT)
And the code would look like this:
app.preferences.rulerUnits = Units.INCHES
Explanation is below:
Final code
// This is single comment tag /* This is multi-comment tag Saleh Ahmed Web:Solution360services.com E-mail: solution360services@gmail.com */ //Set the ruler unit app.preferences.rulerUnits = Units.INCHES //Create new document with title hellophotoshop app.documents.add(100, 50, 72, "helloPhotoshop");