Being respectful to traditions, let us start with a script for drawing “Hello World” in Photoshop. One can use Javascript or VBScript in windows or Applescript in Mac for photoshop scripting. The following Javascript code will produce a “Hello World” photoshop document.
var originalUnit = preferences.rulerUnits preferences.rulerUnits = Units.PIXELS // Create a new document var docRef = app.documents.add( 300, 300 ) // Create a new layer var artLayerRef = docRef.artLayers.add() artLayerRef.kind = LayerKind.TEXT // Write our text artLayerRef.textItem.contents = "Hello World" // Release references docRef = null artLayerRef = null textItemRef = null // Restore unit setting app.preferences.rulerUnits = originalUnit
Code explained :
First of all, we need to keep record of the current unit settings since we are going to change the unit settings according to our preferences. After saving the current units settings, we change the units to PIXELS.
Next, we create a 300X300 pixel document. Then we add a new layer to the new document. Since we want this to be a text layer, we set LayerKind to TEXT.
On the new layer, we write our text, “Hello World”.
At the end, we dereference the variables and restore the previous unit settings.
1 Comment to “Photoshop Scripting : Hello World”
Post comment
Search
News
Blog
- Fetching data from multiple tables in one MySQL query – Part 2
- Fetching data from multiple tables in one MySQL query
- Let’s Go A Hunting
- Java Applet and Javascript message passing
- The Right-Click Menu in Flash
- Stroke hinting
- Python: C++ style cin, cout in Python
- Python: Working in Unicode
- Website Security : Directory Listing Issue
- Hyperlink in actionscript 3


March 20, 2009 in

June 4, 2009 at 11:32 pm
Thanks for the post. Photoshop scripting seems interesting. Can you provide more example or a tutorial where I can learn it more?