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, yes Ben, b.jpg, no 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.

๐Ÿงฎ 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 Image โ–ธ Variables โ–ธ Data Sets โ–ธ Import to load the CSV; a dropdown 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.

Image โ–ธ Variables โ–ธ Define
Layer bindings name โ†’ โ˜‘ Text Replacement ยท var: name photo โ†’ โ˜‘ Pixel Replacement ยท var: photo sale โ†’ โ˜‘ Visibility ยท var: sale Data Set Row 3 of 500 โ–พ Export as Files
Figure 2: Three bindings and an imported data set. Step through rows to proof, then Export Data Sets as Files to render the whole batch at once.

โš ๏ธ Name layers and columns to match

Variables link by name, and a stray space or capital mismatch silently breaks a binding. Name the layer, the variable, and the CSV header identically, and keep the CSV UTF-8 with a header row. 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 JavaScript (ExtendScript) via File โ–ธ Scripts โ–ธ Browse, and the modern UXP scripting platform for newer workflows. 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");
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 (image layer), and a "SALE" badge (a layer to show/hide). Prepare a small CSV with columns name, photo, sale.

Step 1: Name everything ยท 8 min

  1. Rename the layers exactly: name, photo, sale. Match your CSV headers to those names.

Step 2: Define variables ยท 12 min

  1. Image โ–ธ Variables โ–ธ Define. On name tick Text Replacement; on photo tick Pixel Replacement (set the fit method); on sale tick Visibility.

Step 3: Import and proof ยท 10 min

  1. Data Sets โ–ธ Import your CSV. 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 name mismatch).

Step 4: Export the batch ยท 8 min

  1. File โ–ธ Export โ–ธ Data Sets as Files. Choose a naming pattern (e.g. card_[name]) and export.
  2. Optional: run them through your Lesson 6.2 delivery Action to flatten to JPG. Module 6 deliverable: a folder of finished, personalized graphics from one template. ๐Ÿ†

โœ… Project Completion Checklist (Module 6 deliverable)

  • โ˜ Layers named to match 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 layers to match CSV headers exactly
  2. Image โ–ธ Variables โ–ธ Define: Text / Pixel / Visibility
  3. Data Sets โ–ธ Import the CSV; proof rows on canvas
  4. File โ–ธ Export โ–ธ Data Sets as Files with a naming pattern
  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.