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:
๐ง 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.
๐งฎ 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.
โ ๏ธ 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
- Rename the layers exactly:
name,photo,sale. Match your CSV headers to those names.
Step 2: Define variables ยท 12 min
- Image โธ Variables โธ Define. On
nametick Text Replacement; onphototick Pixel Replacement (set the fit method); onsaletick Visibility.
Step 3: Import and proof ยท 10 min
- Data Sets โธ Import your CSV. Step through a few rows and confirm the name, photo, and badge update correctly on canvas.
- Fix any binding that didn't take (usually a name mismatch).
Step 4: Export the batch ยท 8 min
- File โธ Export โธ Data Sets as Files. Choose a naming pattern (e.g.
card_[name]) and export. - 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
- 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.
- Generate 20 social cards for a real list (a team roster, an event lineup) and time how long the manual version would have taken.
- 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
- Name layers to match CSV headers exactly
- Image โธ Variables โธ Define: Text / Pixel / Visibility
- Data Sets โธ Import the CSV; proof rows on canvas
- File โธ Export โธ Data Sets as Files with a naming pattern
- 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.