Working With Data-Driven Graphics in Photoshop Template

Saurabh Jagtap
6 min readNov 5, 2018

--

Let’s imagine a Scenario:
A Graphic designer intern. Newbie in Photoshop and the boss assigns his first task, “I need you to design a template for ID-cards for our upcoming seminar, I mailed you the details of 70 attendees. Make all those 70 ID-cards, you have 12 hours to do so. Go back to work.”
So, he designs and creates the template, copies those 70 names and respective details, pastes it in the template, ‘save as…’ for every 70 times. Pretty easy, you say? but a designer knows the struggle.

Doing the same thing for so many times: easy for sure, but the time it takes and boredom: that’s something you cannot judge. It surely is the pain in the neck, literally!
But, have no fear my fellow Photoshoppers!
What if you’ve given an Excel sheet of all the data and you’d be able to just easily import it in Photoshop template file! That’s something convenient, isn’t it? Alrighty then, without taking this story long, let’s just jump into it!

An Overview:

So, what exactly is going to happen is: We’ll be going to give the names to the layers in template file, import .csv file with data, apply all the values/data given in .csv file to the respective layers in Photoshop template file. That’s it! Now, how to do it? Let’s go through!

Photoshop Template: The Explanation!

Template

There are three text fields with three text layers: Name, Post and Email. Now here’s the little trick: what if we have to put the picture in template? So the solution I found goes like this:
Select the part of the background where you have to add the picture with marque tool and delete the selection, making that part transparent:

Layers in the template with transparent background left where picture will be added

Add the rectangle (Not necessarily rectangle, you can add any shape or image) which will cover the entire transparent part and it should fit perfectly in that transparent part, so if the picture is replaced with that shape, it will clearly display the required picture. Put that shape below/behind the background layer:

Layers in the template with rectangle shape added in the transparent part which will be replaced with picture.

You can set up the template as per your requirement. Lock the layers which won’t be changed.

Setting Up The Template And Variables

This part works exactly same like HTML form. Just like form tags have name attribute, you can set the name of each layers which will work exactly same as that HTML forms. Let’s call it variables. You can define three types of variables:
Visibility variables: show or hide the content of a layer. Takes ‘true’ or ‘false’ values.
Pixel Replacement variables: replace the pixels in the layer with pixels from another image file, in simple words: it’ll replace the layer with picture. This type of variables will be used to replace image with rectangle we added in our template.
Text Replacement variables: replace a string of text in a type layer. This will be used to replace fields like name, email, post etc.

To define variables:
Choose Image > Variables > Define.
Select a layer from the Layer pop‑up menu that contains the content you want to define as a variable.
Select one or more types of variables given above.

In our template, we’ll define/name the text replacement variable to the three text layers we want to define and pixel replacement variable to the rectangle which will be replaced with the picture. That means the layers are defined as follows:
Name: Text Replacement variable with name ‘NameVar’
Post: Text Replacement variable with name ‘PostVar’
Email: Text Replacement variable with name ‘EmailVar’
Rectangle 1: Pixel Replacement variable with name ‘ImgVar’

Note that visibility variables are not defined, they are set to ‘true’ by default, meaning it will be visible even if we won’t set that variable.

These popups are three different popups. Popup for ‘PostVar’ is not included in it, but it’s similar. Layers assigned with variables are shown with an asterisk (*) sign in front of their name in the drop-down list.

In Pixel Replacement variable, you can add method for resizing image. For now, we’ll use ‘conform’. Experiment with other methods as well.

Creating Data set in external file

Now, we have to create a file with all the data in it. Let’s call the collection of data as dataset. You can quickly create a .csv file(comma-delimited) with Microsoft Excel. Simply type all the data in Excel sheet and save it as .csv (comma-delimited) file. First row in the file should contain the variable names which were just assigned to layers and then add the respective values for the variable below that row. In Text Replacement variable, simply add the text you want to be replaced, and in Pixel Replacement variable put the complete path of the picture. Your ultimate goal is to create a .csv file, irrespective of the method. Type all the data by yourself or create a web application using PHP/MySQL and exporting the database tables in .csv format will do the trick too! Right now We’ll be using the .csv file which looks like this:

A .csv file in Microsoft Excel (I’m very bad at names, this is the best I can do😅)

When the .csv file is opened with text editor, it looks something like this:

.csv file when opened with editor like Notepad

Importing and Applying Data set

Choose Image > Variables > Data Sets and click the Import button.

Pop-up for Variables

Navigate to the text file to import. Set up your import options as given below and then Click OK:

Tick ‘Use First Column For Data Set Names.’ : Names each data set using the content of the first column of the text file (the values for the first variable listed). Otherwise, the data sets are named “Data Set 1, Data Set 2, and so on.”

After importing the Data set Successfully, all the values can be seen and the preview for current data set can be previewed:

The drop-down contains all the data set, selecting each data set will preview it on the template, unless ‘preview’ checkbox is checked.

Click OK to apply the .csv file to the template .psd. If you didn’t click on Apply button, the template will go back to it’s initial state with no values (i.e. blank at it was before) but the datasets have been applied so no worries!

The Finale!

Now the only task is to save everything in one go. To save all data sets in .psd file, choose File > Export> Data sets as files. Note that you can only export as .psd file. To export all as .jpg file, you will need Adobe Bridge compatible to your current Adobe Photoshop version.

Pop-up to export Datasets as files. The ‘OK’ button will be available after you select a folder where you want to export the Datasets. Do the file naming as you like. Document name will be same as template name.

Finally, click OK to export all in the folder as .psd, it will take some time to export depending on your data set count (in this case:4 data sets)

Bonus: Export Data sets in .jpg using Adobe Bridge

Start Adobe Bridge. Navigate to the folder where you recently exported all the data sets and saved it as .psd file. Use Ctrl+mouse wheel to increase and decrease thumbnail size.

Adobe Bridge preview after navigating to the desired folder

Go to Tools>Photoshop>Image Processor. Set the options in Image Processor as required and click Run and files will be exported as .jpg files.

Image Processor Pop up

If you do not see options like Photoshop and Illustrator in Tools menu, that means your Adobe Bridge is not compatible with your current Adobe Photoshop version. Download a compatible version of Adobe Bridge and everything will be executed fine.

And That’s how the intern did his work in no time. Also, his boss got impressed with his dedication and gave him a Pre-Placement offer! (Fantasy, obviously!)

Hope you liked it! Thanks for stopping by!

Ref: Create data-driven graphics in Photoshop

--

--