Data-Driven Graphics in Photoshop

There are times we have to create a bunch of similar graphics in Photoshop. Instead of creating each one individually, we can use data sets in Photoshop to whip up as many graphics as we need with just a few clicks. This is useful for thank you cards, scheduled promotional graphics, reminder cards--anything you'd use a template for. You can also use data sets to replace image layers in your Photoshop file, but this post focuses on dynamic text.

I first started using data sets in Photoshop for my day job. We have tradeshows around the country, and we advertise them on branch landing pages and digital signage screens. Rather than create 60-plus graphics by hand, changing the date and time for each one manually, I created a spreadsheet and a PSD template and let Photoshop do most of the work.

The example PSD and CSV data file I used for this post can be downloaded here.

The Data

I like to start with the spreadsheet so I know exactly what my columns (variables) will be. You can really do it either way. The important part is that the column headers, (first row of data,) in your spreadsheet use the same names as the Photoshop variable. You can use any spreadsheet app capable of exporting a CSV file. I use Google Sheets, but Excel or Numbers will work. Once you've got all your data entered, export the sheet as a CSV file. It never hurts to open the CSV in a text editor to confirm that everything looks as it should.

Spreadsheet data

CSV data in a text editor

The Template

Once that's all done, open Photoshop and start creating your template. You'll want one text layer for each column in your spreadsheet. You can do whatever else you like with your template graphics-wise as long as it has those text layers.

Template in Photoshop CC 2014

Text layers that will be assigned to variables later

At this point, go ahead and grab a beer. You've earned it with your wicked Photoshop design skills.

The Mashup

Now let's define some variables. From the Image menu, select Variables, then Define. You'll be presented with a Variables window. From the Layers drop down list, select your first text layer that will need to be populated by data from your CSV file. In my example, the layer is location. I know that my CSV column containing location information is called location, so that's what I type into the Text Replacement: Name field. This name has to match the column header in your CSV or you'll get an error when you try to load the data set. Go back and reference your spreadsheet if necessary to be sure you're typing it in correctly. Repeat this step until every text layer you want to change is assigned to a variable.

Once that's all done, we can load the data set. The drop down menu at the top of the Variables window will let you switch to Data Set view. Click Import. In the Import Data Set window, click Select File and navigate to where ever you saved your CSV, and import it. I like to check the Use First Column For Data Set Names box, as well. If you get any errors, go back and check your variables. The variable names have to match the header row in your CSV. Also, the number of columns in the CSV has to be the same as the number of variables you've identified in Photoshop. I usually get an error every time I load a data set because I've forgotten one of those two rules. Once your data set has been successfully loaded, you can preview the data to make sure everything looks right. When you're satisfied, click OK to return to your Photoshop document.

Output

The next part is a two-stepper. We'll export PSD files first, then convert them to JPG. You could use a different app to batch convert the exported PSD files to something other than JPG, but as far as I can tell, Photoshop's Image Processor will only spit out JPGs or TIFFs.

With your Photoshop template open, and your data set defined, click the File menu, then Export, then Data Sets as Files. In the Export options window, select a folder where you'd like to save the exported PSD files, and tell Photoshop how you'd like the files to be named. Click OK, and let Photoshop do its thing. When it's finished, you'll have a folder full of PSD files that look identical, except for the variable text layers.

From here, you can use Photoshop's Image Processor to batch convert all those PSDs to JPGs. In the File menu, click Scripts, then Image Processor. In section one of the Image Processor window, select the folder where your new PSDs reside. In section two, tell Photoshop where to save the new JPGs. Keep in mind, Photoshop will create an addition JPEG folder automatically. In section three, choose your file options. Click Run, and let Photoshop work its magic. Again.

Navigate to the folder where you told Photoshop to save your JPGs, and admire them. You're done!

I like to hang on to the PSD files in case there are changes down the road. Editing text in one PSD is easier than running the whole data set again.


There you have it. A relatively simple way to create a bunch of graphics. Work smarter, not harder, right?

Have you used data sets in Photoshop? Have any tips to add?