Using variables in Photoshop is akin to using layer comps.  The major different is that when you use variables you are retrieving the data from a data source instead of just turning layers on and off.  Photoshop can use layer names as variable placeholders.  Then, these placeholders can be "filled" with data from a data source which could be a simple text file.  This is akin to using a mail merge program or even server-side scripting like Coldfusion, ASP(.NET), PHP or JSP.  Like Layer comps, this can save you a ton of time if you need to create a multitude of images that have basically the same layout (template) but need different text and graphic on each image (i.e., business cards, trading cards, web ads, web banners, posters, etc.).


Images need to be created or prepared that will be used to replace the placeholders.


Like most database driven applications, it is best to define the database (or data source) BEFORE you build an application. Likewise, we will first start with a data source so we will know in advance how to name the variables using the first row in our data source.  You now need to bind or connect the (layer) variable names with the names in the data source. This is akin to what is done when binding data to a database using server-side technologies (i.e., ColdFusion, etc.).  There are two ways to create a data source: external or internal. In this tutorial we will use an external data source.

To create a data source OUTSIDE of Photoshop, follow the procedure below:


employee_full_name start_date extension notes photo department_name
Ann Ricoh 12-Mar-07 2563 Ann enjoys bike riding and reading. images/ann_ricoh.jpg Finance
Bob Anderson 3-Mar-07 8765 Bob enjoys spending time with family and friends. images/bob_anderson.jpg Finance
Carol Green 1-Feb-07 9863 Personal interests include mountain climbing and snow skiing. images/carol_green.jpg IT
Debra Samson 5-May-06 2364 Loves working with communities groups to help enhance her community. images/debra_samson.jpg IT
Jason Taylor 15-Jan-07 2589 Love reading and writing for local organizations. images/jason_taylor.jpg Operations
Josiah Louis 11-Feb-07 5896 Personal interests include playing basketball and football. images/josiah_louis.jpg Human Resources
Mary Thompson 23-Jul-08 5236 Personal interests include modeling and swimming. images/mary_thompson.jpg Marketing
Rickey Long 20-Apr-07 8593 Loves doing outdoors activities with friends. images/rickey_long.jpg Finance
Sam Donaldson 6-Feb-07 3345 Loves spending time with his wife and kids doing outdoors activities. images/sam_donaldson.jpg Finance
Sheila Davis 11-Feb-07 3434 Love to help other less fortunate than herself. images/sheila_davis.jpg Finance
Sue Williams 5-Apr-07 2563 Loves to sing and dance. images/sue_williams.jpg Finance
Tammy Jones 12-Apr-07 7485 Enjoys going to the movies. images/tammy_jones.jpg Operations

NOTE: Path names to images can be absolute or relative to the folder where the images are located (i.e., images).


Create a layout template using static and dynamic text and graphics layers as placeholders.
IMPORTANT: Because the layer names will be treated as variables later, you must follow the following naming convention for layers that will be dynamic: Variable names must begin with a letter, underscore, or colon and cannot contain spaces or special characters (except for periods, hyphens, underscores, and colons).

Create Background Layer

  1. Create a new file with the desired dimension you need for your project. (The Photoshop default size will be used to demonstrate this example)
  2. If necessary, create a background layer or import a background image. (A gradient background is used in this example -- See below)

    Create Dynamic Text Placeholder(s) via Text tool

  3. Create a text layer as a DYNAMIC text placeholders and adjust the font size and style to your liking and then give the layer the SAME name as in the data set header name you just created. (In this case, employee_full_name is used for the first text field.).
    NOTE: Remember, by naming the layer the same as the header, it will be treated as a variable for the text placeholder later.
    TIP: Use the longest text in your data source as the length for each text placeholder so that the text does not get cut off.  It is best NOT to simply click on the canvas to create a text object. Instead "drag out" a text area that is almost the width of the canvas and "center" the text inside of the text object using the align center tool. See example below:


  4. Repeat the previous steps to create additional dynamic text holder(s) as needed. (Here, four more text placeholders were added.)
    NOTE: The text placeholders in this case are left justified instead of centered and the notes font size has been reduced.
    TIP: Turn on the grid to assist you in aligning text placeholders if needed.

    Create Dynamic Graphic Placeholder(s) via Rectangle Tool or a Real Image

  5. Similiar to the text placeholders, use the Rectangle Tool (U) with the Fill pixels option selected in the Option bar to "draw" a graphic placeholder that represents the typically size of the image that they will be replaced later and then give the layer the SAME name as the data set header name you created earlier.
    TIP: You could also use an actual image as a placeholder; however, since it will be replaced with data from the data set later, it is not necessary.  This is a better approach because it helps you visualize your project and you don't have to find out the image size if they are set already.  In fact, in this case, this is just what was done.
    TIP: Just like the text field, you can also "style" the image placeholder with layer styles as was done in the screen shot below.

  6. Repeat the previous steps to create additional dynamic graphics holder(s) as needed, if needed.

    Create STATIC text fields or STATIC graphics

  7. Create STATIC text fields via Text tool or create / import STATIC graphics that will be the same on all images. (In this example, only static text fields are added.)
    TIP: You can duplicate the existing dynamic text fields and then edit and move them into place so that you don't have to type them in. If you do, don't forget to rename the layers to something more descriptive (i.e., department_name to department_name static text so that you don't get them confused with the dynamic text fields when you make them variables.
    NOTE: Once you are completed adding dynamic text/graphic and static text/graphics, you have create a template that will be used in the next section.


The dynamic layers names in the Layers Panel need to be "matched" to the header names in the data source for both the text and graphics layers.

Choose Image > Variables > Define... and then make the following changes.

Create Text Data Set

  1. Ensure that Define (CTRL+1) is selected and not Data Set (CTRL+2) in the first drop-down menu.
  2. Select a Text Layer from the Layer: drop down menu. (In this case, employee_full_name was selected)
  3. Select the Text Replacement checkbox and then give the variable the SAME name as the name in the Layer: drop-down box you selected earlier.
    NOTE: If you wanted to create an OPTIONAL TEXT variable, select the Visibility checkbox and enter or select a variable.  A good use for this option would be if you were selling some products and you want to have a SOLD text appear across items that have been already sold.  You could create a TRUE and FALSE variables in your data source to determine when to show the text..
    NOTE: An asterisk ( * ) will appear next to the layer name in the Layers text field.
    NOTE: If you choose an existing variable to link to a link icon will appear next to the Name text field.
  4. Repeat this process for the other text layers. DO NOT select the static layers. (In this case, four more layers were defined (department_name, st art_date, extension, and notes)
    NOTE: You can use the left and right navigation arrows on the right side of the Layer  text field to move between layers or select a Layer from the Layer: drop-down menu.

    Create Graphic Data Set

  5. Select a Graphic Layer from the Layer: drop down menu. (In this case, photo)
  6. Ensure that the Pixel Replacement checkbox is selected and then give the variable the SAME name as the Layer: drop-down box you selected earlier.

    NOTE: If you wanted to create an OPTIONAL IMAGE variable, select the Visibility checkbox and enter or select a variable.  A good use for this option would be if you were selling some products and you want to have a SOLD image appear across items that have been already sold.  You could create a TRUE and FALSE variables in your data source to determine when to show the image.
    NOTE: While you can define variable for any custom background layer (i.e., Background copy), you cannot define variables for the default Background layer.

  7. Set the Method (In our example, the Fit method was selected.  However, because all of our images are of the same size, we could have also used the As Is option).
    TIP: Select a method and then hover over the Method text field to see a visual and text on how that method works:

    NOTE: You can also select Clip To Bounding Box to clip areas of the image that do not fit in the bounding box. This option is available only when the Fill or As Is replacement method is selected except for the Conform method.
    NOTE: You can also click on one of the Alignment alignment point (square) except for the Conform method to  resized image to the center or to an edge.

  8. Repeat this process for any other graphic layer (In this case, there is none.)
    TIP: You can use the navigation arrows to move between layers.
    : You can also set the visibility of both a text or graphic layer.
    NOTE: To rename a variable, enter a new name in the Name text box. To remove a variable, simply deselect it.


Create a data set from the text file as the data that will fill the placeholders with real values.

  1. While still in the Variables dialog box, click the Import.... button.

  2. In the Import Data Set dialog box:
    1. Click the Select File... button and  then select the text data file you created earlier and then click the Load button followed by the OK button.
    2. Select Automatic from the Encoding: drop-down menu.
    3. Select Use First Column For Data Set Names checkbox.
    4. Click OK to close Import Data Set dialog box.
      NOTE: You will SEE the Variables dialog box get populated with variable data. Now the data variables are bound together and given their corresponding values.
      NOTE: You can then select the Preview checkbox and then click the right and left arrows near the Data Set: text field to preview result on the canvas.
      NOTE: You aan also preview the data set by selecting Image . Apply Data Set adn select a data set that you would like to preview. If you click on the Apply button, you will change the current layer.

  3. Click OK to close the Variables dialog box and to return to Photoshop.


You can now export the the result  as individual Photoshop psd files.

Choose File > Export > Data Sets as Files.... In the dialog box, select your destination folder and file naming options and then click OK to export each data set "record" as an individual Photoshop psd file.
NOTE: Each file is a layered psd file and can be open and edited separately.
TIP: To flatten these images, select File > Scripts > Image Processor... or select them in Bridge and choose Tools > Photoshop > Image Processor.

You can also use Bridge to create a Web Photo Gallery (WPG) by selecting the images in Bridge and choosing the Output option.

(Bonus) Transforming Graphics using Layer Comps

Normally if you try to transform (i.e, rotate) an image on a layer, when it is replaced by the real image it will be straight again.  To resolve this problem, create a script to rotate that particular layer and then preform a Batch process on those images

Create a simply Action to:

  1. Select a layer (in this case, the photo).
    NOTE: Since the photo layer is common to all images, the Batch process will work correctly.
  2. Rotate the image
  3. Save the Action
  4. Run a Batch process using the Action you just created to transform (i..e., rotate) the image in all psd files.