Creating your own backgrounds with Adobe Photoshop Scripting

Some Photoshop versions ago (actually I can’t tell which Photoshop version featured scripting first) Adobe developed the capability of executing scripts inside Photoshop.

A script is a series of commands that tells Photoshop to perform a set of specified actions, such as applying different filters to selections in an open document. These actions can be simple and affect only a single object, or they can be complex and affect many objects in a Photoshop document. The actions can call Photoshop alone or invoke other applications.

Scripts automate repetitive tasks and are often used as a creative tool to streamline tasks that might be too time consuming to do manually. For example, you could write a script to generate a number of localized versions of a particular image or to gather information about the various color profiles used by a collection of images.

My case was a bit different: I was looking for a background full of numbers to use in the enhanced version of my Flash math game in less than 2KB so I started googling a bit until I stumbled upon a series of images like these ones:

I wanted something like that but all images I found were taken from sites like Depositphotos or similar sites so I told to myself: “are they really charging for some stuff I can do in a couple of minutes”? And I decided to create a Photoshop script to do something similar on my own.

Let me show you how i managed to do a background with numbers:

First, Photoshop lets you choose the language you prefer among VBScript, AppleScript and JavaScript. I used JavaScript because it’s the only one working both on Windows and Apple machines.

Then, Adobe provides a tool called ExtendScript Toolkit you can find in your Program Files -> Adobe -> Adobe Utilities folder and which allows you to test your scripts on the fly, but you can use your favourite text editor as long as you save your scripts with jsx extension then load them in Photoshop with File -> Scripts -> Browse.

So, I made a script to write 1000 random numbers in random positions with a random color and a random alpha, with this script:

And once executed here’s an example of what I got:


Now I am able to make virtually any kind of numbers-letters background in a matter of seconds.

Download the source code and the resulting PSD.

  • Thanks for the script. I tested it and it works but also it takes some time. Scripted Patterns is one of amazing features in Photoshop which is usually overlooked by users. I am about to go beyond actions and variables and scripting patterns can be good starting point. Thanks for highlighting this feature and Photoshop capabilities.

  • Thanks for the script, i have linked to the article on my new blog :)

  • Thank you for the script Mr. Emanuele. Im still new in photoshop and this article helped me.