Working With Data-Driven Graphics in Photoshop Template
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!
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:
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:
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.
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:
When the .csv file is opened with text editor, it looks something like this:
Importing and Applying Data set
Choose Image > Variables > Data Sets and click the Import button.
Navigate to the text file to import. Set up your import options as given below and then Click OK:
After importing the Data set Successfully, all the values can be seen and the preview for current data set can be previewed:
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.
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.
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.
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!