Create the base graphic you want to use as the template.
Use layers to separate the elements that you want to change in the graphic.
Use data-driven graphics to work with templates created in Photoshop
Here's a scenario for you:
It's your first week at work and you need to create five versions of a web banner with varying text and images using a single template design.
Did you know that data-driven graphics will be the best way to get your job done?
Follow these general steps to create consistent designs with different text and images using data sets:
Create the base graphic you want to use as the template.
Use layers to separate the elements that you want to change in the graphic.
Define variables in the graphic. As we know, variables specify the parts of the image that need to change.
Create or import the data sets. Create the data sets in the template or import them from a text file.
Preview the document with each data set. Before you export the file, check the preview to know how your final image will appear.
Generate your graphics by exporting them with the data. We recommend using the Photoshop (PSD) format.
Use variables to define which elements in a template need to change. You can define three types of variables.
Visibility Variable shows or hides the contents of a layer.
Text Replacement variables replace a string of text in a type layer.
Pixel Replacement variables replace the pixels in the layer with pixels from another image file.
You cannot define variables when working with the Background layer.
Go to Image > Variables > Define.
Select your preferred layer from the Layer pop‑up menu with the content to be defined as a variable.
Select one or more types of variables: Visibility, Pixel Replacement, and Text Replacement.
Visibility: Shows or hides the content of the layer or the layer group
Pixel Replacement: Replaces the pixels in the layer with pixels from another image file
Text Replacement: Replaces a string of text in a type layer
Do one of the following:
Enter a name for the variable in the Name field. Variable names can begin with a letter, underscore, or colon. They cannot contain spaces or special characters (except for periods, hyphens, underscores, and colons).
Or,
Choose an existing variable from the Name drop-down menu to link the layer. Layers linked to the same variable are shown next to the Name menu, along with the link icon.
Follow these steps when using Pixel Replacement variables.
To define variables for another layer, choose a layer from the Layer pop‑up menu and select OK.
An asterisk appears next to the name of a layer that contains variables. You can use the navigation arrows to move between layers.
Go to Image > Variables > Define.
Choose the layer that contains the variable from the Layer pop‑up menu.
To rename the variable, enter a name in the Name text box.
Variable names must begin with a letter, underscore, or colon and cannot contain spaces or special characters (except for periods, hyphens, underscores, and colons).
Deselect the variable to remove it.
A data set is a collection of variables and associated data. You can define a data set for each version of the graphic that you want to generate.
Do one of the following:
Or,
At least one variable needs to be defined before the default data set can be edited.
Select the new data set button () to create a new data set based on the current data set.
Select a variable from the Name drop-down list.
Edit the variable data:
For Visibility variables, select Visible (to show the layer’s content) or Invisible (to hide the layer’s content).
For Pixel Replacement variables, select Select File and then the replacement image file. Select Do Not Replace before the data set is applied to leave the layer in its current state.
The Do Not Replace button does not reset the file to its original state if another replacement has been applied previously.
Edit, rename, or delete your data set by first choosing it from the Data Set menu and editing the options. Use the arrow icons to move between data sets. Hit the Delete icon to delete a data set.
Apply the contents of a data set to your base image even while leaving the variables and data sets intact.
This will change the view of your image to contain the values of the data set. Use the Preview option to view how each version will appear with each data set.
Go to Image > Apply Data Set to select the data set from the list and preview the image in the document window.
Select Apply to apply the data set. Hit Cancel if you only want to preview and don’t want to change the base image.
You can also apply and preview a data set by navigating to Image > Variables > Data Sets and checking the Preview checkbox.
Applying a data set overwrites your original document.
Once you've defined the variables and one or more data sets, you can generate batch mode output images using these data set values. The output generated will be in the form of PSD files.
Go to File > Export > Data Sets As Files.
Use the Select Folder button to select a destination directory for your files.
Choose data sets to export and hit OK.
You can quickly create a large number of data sets by using an external text file that contains all the variable information and importing it into your PSD document containing variables.
One method is to enter your data into a text file or Microsoft Excel spreadsheet and then export it to a tab or comma-separated file.
Follow the given syntax for your external text file (where each line that starts with “Variable” or “Value” is an entire line by itself in your file):
VariableName1<sep>VariableName2<sep> <sep>VariableNameN <nl> Value1-1<sep>Value2-1<sep><sep>ValueN-1<nl> Value1-2<sep>Value2-2<sep><sep>ValueN-2<nl> Value1-M<sep>Value2-M<sep><sep>ValueN-M<nl>
All the variable names are listed on the first line, in the order that the values are given in subsequent lines. Each subsequent line represents one data set, with the values for each variable given.
To create multiple lines of text in a single line of text in a data set, enclose the text in double quotes and insert hard returns in the tab- or comma-separated file where you want the breaks to occur.
External text file | Syntax elements |
<sep> |
Either a comma-separated (CSV) or a tab (tab-delimited) file that separates each variable name or value |
<nl> |
A newline character that ends each data set and can be a line feed, carriage return, or both |
“true” and “false” |
Allowed values for a visibility variable |
Spaces |
Spaces around the delimiter are removed when parsing the file; between words in a value string (e.g., two of a kind) spaces are maintained and leading and trailing spaces are maintained if enclosed in double quotes (e.g., “one kind ”) |
Double quotes |
Can be part of a value if preceded by another double quote (e.g., ““B”” would be “B” in the data set) |
If <sep> or <nl> is part of the variable value, then you need to enclose the entire value within double quotes.
All the variables defined in your PSD file must be defined in the text file, or an error will display if there is a mismatch between the number of variables in the text file and your document.
Create a text file using a template for flowers that holds variables for tulips and sunflowers. It could be as shown here:
{contents of FlowerShow.txt} Variable 1, Variable 2, Variable 3 true, TULIP, c:\My Documents\tulip.jpg false, SUNFLOWER, c:\My Documents\sunflower.jpg false, CALLA LILY, c:\My Documents\calla.jpg true, VIOLET, c:\My Documents\violet.jpg
You can use a relative path for the image location if the text file is in the same folder as the image file. For example, the last item in the example can be: true, VIOLET, violet.jpg.
Do one of the following:
Or,
Set up your import options.
Set the encoding of the text file or leave the setting Automatic before selecting OK.