Skip to main content

Module 6 โ€ข Lesson 3๐Ÿ—ƒ๏ธ Data-Driven Graphics & Scripting

The Module 6 deliverable. When the brief is "500 name badges", "a personalized banner per city", or "every product in the catalog", you stop designing files and start designing a template plus data. Variables bind layers to a spreadsheet; a little scripting handles what variables can't.

๐Ÿ“š What You'll Learn

By the end of this lesson, you will be able to:

  • Define Variables that bind layers to data: text, visibility, and pixel replacement
  • Import a Data Set from a CSV and preview each row on the canvas
  • Export Data Sets as Files to render one graphic per row
  • Understand where scripting begins and read a simple ExtendScript / JS example
  • Choose between Actions, Variables, and scripts for a given job

โฑ๏ธ Estimated Time: 60 minutes

๐ŸŽฏ Project (Module 6 deliverable): One template that outputs a whole batch of personalized graphics from a CSV โ€” text, image, and visibility all driven by data.

In This Lesson

๐Ÿ‘ค The Goal: One Template, Hundreds of Outputs

A batch of personalized cards. On the right, the manual way: duplicate the file, retype the name, swap the photo, save โ€” per person, forever. On the left, one template plus a CSV; Photoshop renders every row automatically. Drag the handle:

Template + data One at a time
A diagram of the principle. Design the card once, describe the differences as data, and let Photoshop render the rows. Ten or ten thousand costs the same effort.

๐Ÿง  Mental Model: Template + Data

A data-driven document has two halves. The template is your design with certain layers marked as variable. The data is a table where each column maps to a variable and each row is one output. Photoshop's Variables feature binds them: define which layers change and how, import the table as Data Sets, and each row becomes a finished graphic.

There are exactly three kinds of variable: Text Replacement (swap the words in a type layer), Pixel Replacement (swap the image in a layer, with fit rules), and Visibility (show or hide a layer). Almost any personalized-graphics job decomposes into those three.

data.csv name, photo, sale Ana, a.jpg, true Ben, b.jpg, false Text โ†’ "name" layer Pixel โ†’ "photo" layer Visibility โ†’ "sale" badge
Figure 1: Each CSV column drives one variable type. Text, pixel, visibility โ€” bind those three and most personalized-graphics briefs are solved. Visibility values must be true or false; Photoshop rejects yes/no.

๐Ÿงฎ Variables & Data Sets

Open Image โ–ธ Variables โ–ธ Define, pick a layer, tick the variable types it needs, and name each variable to match a CSV column. Then open Image โ–ธ Variables โ–ธ Data Setsโ€ฆ and click Import to load the CSV; with Preview on, the Data Set menu lets you step through rows and see each on the canvas. Finally File โ–ธ Export โ–ธ Data Sets as Files renders one PSD (or, via an Action, a JPG/PNG) per row.

Variables dialog (Define + Data Sets pages)
Layer bindings name โ†’ โ˜‘ Text Replacement ยท var: name photo โ†’ โ˜‘ Pixel Replacement ยท var: photo sale โ†’ โ˜‘ Visibility ยท var: sale Data Set Row 3 of 500 โ–พ (Data Sets page, Preview on)
Figure 2: The Define page's three bindings and the Data Sets page's row selector, shown together. Step through rows to proof, then use File โ–ธ Export โ–ธ Data Sets as Files to render the whole batch at once.

โš ๏ธ Name layers and columns to match

Each variable binds to the CSV column whose header matches its variable name, and a stray space or capital mismatch breaks the import. Variable names can't contain spaces and must start with a letter, underscore, or colon. Naming the layer the same is a helpful habit, not a requirement. Keep the CSV UTF-8 with a header row, write Visibility values as true/false, and give Pixel Replacement values as full file paths (or just file names, with the images in the same folder as the CSV). Proof a few rows on-canvas before exporting five hundred.

๐Ÿ’ป Where Scripting Begins

Variables cover "same layout, different content." When you need real logic โ€” loop over files, do math, rename by pattern, call an API, decide based on pixel values โ€” you reach for scripting. Photoshop runs classic ExtendScript (.jsx) and newer UXP scripts (.psjs) via File โ–ธ Scripts โ–ธ Browse. The example below is ExtendScript, which is still the easiest to find snippets for. You do not need to be a programmer to adapt a snippet.

Here is a complete, readable example: open every JPG in a folder, resize to 2000px on the long edge, and save a web copy โ€” the kind of loop an Action alone can't express cleanly:

// resize-folder.jsx  โ€”  File โ–ธ Scripts โ–ธ Browse to run
var inputFolder  = Folder.selectDialog("Choose a folder of images");
if (!inputFolder) { throw new Error("No folder chosen."); }
var files = inputFolder.getFiles(/\.(jpg|jpeg|png)$/i);

for (var i = 0; i < files.length; i++) {
    var doc = app.open(files[i]);
    var longEdge = 2000;
    var scale = longEdge / Math.max(doc.width.value, doc.height.value);
    doc.resizeImage(doc.width * scale, doc.height * scale);

    var out = new File(inputFolder + "/web_" + doc.name.replace(/\.[^.]+$/, ".jpg"));
    var opt = new JPEGSaveOptions();
    opt.quality = 10;
    doc.saveAs(out, opt, true);
    doc.close(SaveOptions.DONOTSAVECHANGES);
}
alert("Done: " + files.length + " images resized.");

โœ… You can read code before you can write it

Notice you can already follow this: pick a folder, loop the files, compute a scale, resize, save, close. Start by tweaking values (the 2000, the quality) in snippets like this. Reading and adapting is a real, employable skill on its own.

๐Ÿ› ๏ธ Guided Build: A Data-Driven Batch

Design a simple card template with a name (type layer), a photo (a plain pixel layer, not a Smart Object: Pixel Replacement only works on pixel layers), and a "SALE" badge (a layer to show/hide). Prepare a small CSV with columns name, photo, sale: put the photos in the same folder as the CSV, list their file names in the photo column, and write true or false in the sale column.

Step 1: Name everything ยท 8 min

  1. Rename the layers exactly: name, photo, sale. You'll give the variables the same names, and the CSV headers must match the variable names.

Step 2: Define variables ยท 12 min

  1. Image โ–ธ Variables โ–ธ Define. On name tick Text Replacement; on photo tick Pixel Replacement (set the method: Fit, Fill, As Is, or Conform); on sale tick Visibility. Name each variable to match its CSV header.

Step 3: Import and proof ยท 10 min

  1. Image โ–ธ Variables โ–ธ Data Setsโ€ฆ โ–ธ Import your CSV. Tick Use First Column For Data Set Names (your first column is name). With Preview on, step through a few rows and confirm the name, photo, and badge update correctly on canvas.
  2. Fix any binding that didn't take (usually a header/variable-name mismatch, a yes/no instead of true/false, or a photo path Photoshop can't find).

Step 4: Export the batch ยท 8 min

  1. File โ–ธ Export โ–ธ Data Sets as Files. In File Naming, choose Data Set Name (the name column, thanks to the import option), add any fixed text you like, and export. Photoshop writes one PSD per row.
  2. Optional: flatten them to JPG with File โ–ธ Scripts โ–ธ Image Processor, or a copy of your Lesson 6.2 delivery Action with its conditional crop and Fit Image steps removed (those would crop and resize the cards). Module 6 deliverable: a folder of finished, personalized graphics from one template. ๐Ÿ†

โœ… Project Completion Checklist (Module 6 deliverable)

  • โ˜ Variable names (and layers) matching the CSV headers exactly
  • โ˜ Text, Pixel, and Visibility variables defined
  • โ˜ CSV imported as a data set, several rows proofed on canvas
  • โ˜ Data Sets exported as files with a clear naming pattern
  • โ˜ (Optional) finished via a delivery Action / droplet

๐Ÿง— Now You: Solo Variation

๐ŸŒŸ Your challenge

  1. Add a second visibility variable (e.g. a "VIP" ribbon) and a color-swap via a visible/hidden tint layer, all from new CSV columns.
  2. Generate 20 social cards for a real list (a team roster, an event lineup) and time how long the manual version would have taken.
  3. Open the sample script, change the long edge and output format, and run it on a test folder. Then add a line that skips files already starting with web_.

Going further: combine everything โ€” a data set feeding a template whose art lives in linked Smart Objects (Module 5), exported by an Action (6.2). That stack is a genuine production pipeline.

๐Ÿณ Recipe Card: Data-Driven

Template + data โ†’ batch

  1. Name each variable to match its CSV header exactly (matching layer names is a helpful habit, not a requirement)
  2. Image โ–ธ Variables โ–ธ Define: Text / Pixel / Visibility
  3. Image โ–ธ Variables โ–ธ Data Setsโ€ฆ โ–ธ Import the CSV (first column as names; Visibility = true/false); proof rows on canvas
  4. File โ–ธ Export โ–ธ Data Sets as Files, named by Data Set Name
  5. Reach for scripting when you need loops, math, or logic

Mantra: design the difference as data, and the count stops mattering.

๐Ÿ““ Learning Journal

Add to your journal after this lesson:

  • Key concepts you learned
  • Techniques that clicked for you
  • Questions or confusion points to revisit
  • Ideas you want to try
  • Your progress and feelings about learning this

โœ๏ธ This lesson's prompt: What in your work is really "one design, many values"? Sketch the template and the columns its data set would need. Seeing jobs as template-plus-data is the mindset shift of this module.

๐Ÿ“ Module 6 Summary

๐ŸŽ“ Key Takeaways

  • Generative fill is a fast assistant for gaps, removals, and harmonizing โ€” curated and hand-finished, never shipped raw.
  • Actions record steps; conditionals branch them; batches and droplets run them over folders.
  • Variables + Data Sets turn a template plus a CSV into hundreds of finished graphics.
  • Scripting takes over when you need loops, math, or logic Actions and variables can't express.

๐ŸŽ‰ What You've Accomplished โ€” Across All of Module 6

You have added speed and scale to your craft: AI assistance for the tedious parts (6.1), recorded and conditional automation (6.2), and data-driven production plus a first real taste of scripting (6.3). You can now output at volumes that were simply impossible by hand โ€” the difference between an artist and a one-person studio.

โ“ Common Questions at This Stage

Variables or scripting for a big job?

If it is "same layout, changing content", Variables are faster to set up and need no code. The moment you need conditionals beyond show/hide, calculations, external lookups, or per-file logic, a script is the right tool. They also combine โ€” export data sets, then script the post-processing.

Do I have to learn to code to be a pro?

No โ€” but being able to read and adapt a snippet dramatically expands what you can automate. Treat scripting like OpenType or LUTs: one more tool you reach for when it fits, not a separate career.

๐Ÿ”ญ Looking Ahead

You have finished the heart of the pro toolkit. The Going Further tier now widens the lens. Module 7 โ€” Multi-Shot Techniques covers panoramas, HDR, focus stacking, and timeline animation โ€” combining many frames into one impossible image or a moving one.

โœ… Before the Next Module

  • Ship one data-driven batch (10+ outputs) from a single template.
  • Adapt the sample script and run it on a test folder.
  • Write your Learning Journal entry.

๐Ÿ“š Additional Resources

๐ŸŒŸ Encouragement for the Journey

Automation is the quiet multiplier on everything else you have learned โ€” it lets your best work scale without your best hours. You now think in templates, data, and scripts, not just files. Two modules remain. Let's widen the lens and combine many frames into one.