The other essential piece of a data-driven graphic is the data set, which is the actual content Photoshop uses to fill in the variables. You can define a data set inside Photoshop or in an external document. In my example, this is where I associate each product with its price, image, and organically grown status. To start with, I'll make data sets for pears and bananas.
To define a data set inside Photoshop:
Choose Image > Variables > Data Sets, or if you're already in the Variables dialog box, choose Data Sets from the pop-up menu at the top of the dialog box.
Click the Create New Data Set button and then enter a name for Data Set. In my example, I make one called Pears (Figure 20.3).
In the Variables section, choose a variable from the Name menu or click a variable in the list.
For Value, specify the value of the variable you selected.
In my example, for my variable named "image" I clicked Select File to locate the pear.psd file that is the image that goes with the pear product.
Repeat step 4 for every variable in the list. For the pear coupon I'm making, I enter the product name ("product" variable), its price ("price" variable), and set its "organic" variable to Visible.
Repeat steps 2 through 6 for each data set. I did that for each product that needed a coupon. You can navigate among existing data sets by clicking the pop-up menu button or the arrows to the right of the Data Set name.
Changing data sets changes all the variables over the template. In my example, the Organic type layer appears only with the pear data set because its "organic" variable is set to Visible for that data set.
You can also set up a data set outside Photoshop using a database or spreadsheet program and then export the data set as an ordinary comma-delimited or tab-delimited text file. I'll show how my example would look coming from Microsoft Excel.
To create a data set outside of Photoshop:
Use a database or spreadsheet program to create a record of each data set, its variables, and their values (Figure 20.4). My example shows Microsoft Excel.
Path names to image files must be absolute path names that are legal for your platform. For example, a path in Windows XP should look similar to this:
C:/My Documents/<folder name>/<filename>
A Mac OS X path should look similar to this:
Macintosh HD:Users:<username>:<folder name>:<filename>
From the database or spreadsheet program, save or export the document as tab-delimited or comma-delimited text.
In Microsoft Excel, the option to save as comma-delimited text is available in the File > Save As dialog box. Tab-delimited and comma-delimited formats produced by Microsoft Excel and common database programs should work fine. If you're generating your own, the full requirements for the data set text file format are in the Photoshop help file in the topic "Importing Data Sets from External Files."
In Photoshop, choose File > Import > Variable Data Sets; or if you're already in the Data Sets dialog box, just click Import.
In the Import Data Set dialog box, specify options and click OK (Figure 20.5). You can usually leave the Encoding set to Automatic. Enable the Use First Column For Data Set Names checkbox if the original spreadsheet listed the data set names down the first column instead of across the first row.
In the Variables dialog box, leave the Preview checkbox enabled to see if the variables affect the document correctly.