Bulk Image Captions from CSV
Operator: Abdulla Al Fahad. How tools are built and checked
Photos and spreadsheet rows rarely pair up perfectly. A folder of 60 headshots against a staff sheet of 63 rows leaves three people without a photo, and one file is called IMG_014.JPG while the sheet says img_014. This page matches the two by file name, tells you which rows have no picture and which pictures have no row before anything is rendered, and then draws a caption built from that row's columns, such as {name} and {title}, onto each picture.
The result is one ZIP holding the captioned pictures and a captions-report.csv that lists every picture as captioned, skipped or failed, and every row that named a picture that was never added.
Key features
- Picture-to-row matching by file name, ignoring case and folders, with a name-only match when the cell has no extension
- Up to four text boxes per picture, each with {column} fields that are filled from the row
- Font family, size, bold, colour, outline, alignment, an anchor point and an optional translucent background bar
- Shrink-to-N-lines for long values, so a long job title drops to a smaller size instead of running to a fourth line
- Preview any picture with its own row before running the batch
- A ZIP of captioned JPG or PNG files that includes captions-report.csv
File-name matching, text templates and box layout
A run takes up to 100 pictures of up to 25 MB each, read one at a time and identified by their first bytes rather than their extension; an animated GIF is captioned on its first frame, and a picture over 4096 px on the long side is scaled down when the batch runs. The sheet can be CSV, TSV or XLSX (first sheet) up to 25 MB, or pasted text. A binary file given as a CSV is refused.
A cell matches a picture when its last path component, lower-cased, equals the picture's name, so photos/IMG_014.JPG in the sheet matches img_014.jpg. A cell with no extension, such as img_014, matches by name alone. When two rows name the same file the first row is used and the duplicate is reported. Rows whose file name is empty are ignored and counted.
Text size and position are percentages of the picture's own size: size is a share of its width, the anchor is a share of its width and height, and the box width is a share of its width. The same settings therefore give the same look on a 1200 px and a 4000 px picture, and a portrait and a landscape picture differ only in how many lines the text wraps to. The box is nudged back inside the picture if the anchor would push it over an edge.
Common use cases
- A conference badge-photo set: 140 attendee photos split into two runs of 70, each captioned with {first} {last} on the first line and {company} on a second box at 3.5 percent of the width, on a 55 percent black bar.
- A product catalogue: 80 shots named by SKU, captioned with {sku} at the top left and {price} at the bottom right using two boxes, both in white with a black outline of 12 percent of the text size.
- A photo contest where entry numbers should replace file names: the sheet maps each camera file name to {entry}, and a single large number at the bottom centre is stamped on each picture.
How to use this tool
- Add the pictures, then the spreadsheet, and check the match summary; pick another column if the wrong one was chosen.
- Write each caption as a template, place it with the anchor and width fields, and flip through the preview to check long values.
- Choose JPG or PNG and press Caption and download ZIP. Read the list of misses under the button, or open captions-report.csv.
Example
Three pictures and five rows (the header is row 1 of the sheet)
pictures: img_001.jpg, IMG_002.png, extra.jpg
file,name,role
IMG_001.jpg,Ana,CEO
photos/img_002,Bo,CTO
missing.png,X,
img_001.JPG,Dup,
(empty),E,
template: {Name} - {role} {nope}What the page and captions-report.csv say
2 of 3 pictures matched a row: img_001.jpg uses row 2, IMG_002.png uses row 3
No row for: extra.jpg
1 row names a picture that was not added, for example “missing.png” (row 4)
1 file name appears in more than one row, such as “img_001.jpg”; the first row is used
1 row has an empty file name and is ignored
template for row 2: "Ana - CEO ", with {nope} flagged as an unknown columnTips for best results
- Set Shrink to 2 lines on a box that holds a long field like a job title. The text shrinks to as little as 40 percent of its set size to fit, and only then adds a line.
- Use two boxes rather than a line break inside one when the lines need different sizes; each box has its own size, colour and bar.
- Preview the picture with the longest value, not the first one. Wrapping is the thing most likely to differ between rows.
Common pitfalls
Matching is by name, so two different pictures called photo.jpg from different folders both get the first row's text. Rename them before adding. Row numbers on the page, in the preview picker and in captions-report.csv count the header as row 1, so the first data row is 2, as a spreadsheet program shows it.
Common errors and how to fix them
- 0 of N pictures matched
- The file-name column is probably wrong; pick another one in the list. If the sheet holds names without extensions, check that they equal the picture names exactly, apart from case.
- A caption wraps to many lines or covers too much of the picture
- The text size is a share of the picture's width and the box width a share too, so a long value in a narrow box wraps often. Widen the box, lower the size, or set Shrink to 2 lines so the text gets smaller before it gets taller.
- A box prints nothing for some rows
- The value for that row is empty or the placeholder does not match a column name. Names are compared ignoring case and surrounding spaces, but a typo or an extra word will not match.
Best practices
- Row order does not matter. Pictures are paired by name, not by position, so you can sort or filter the sheet freely and the pairing stays the same.
- Put the file-name column in a template only if you want it printed; once matching is done it is an ordinary column like any other.
How a row becomes a caption
For every picture the page finds the row, replaces each {column} with that row's value (column names are matched ignoring case and spaces; an unknown name prints nothing and is flagged beside the box), and wraps the text greedily to the box width with the canvas's own text measurement. A word wider than the box is broken between characters.
Pictures are decoded, drawn, encoded and released one at a time, so memory holds about one picture and its output blob at once. The finished blobs are packed into a ZIP without recompression. If the encoded pictures together pass 600 MB the run stops with a message that says how many were done, so a very large batch fails clearly rather than freezing the tab.
Frequently asked questions
How is this different from stamping one watermark on every picture?
A watermark repeats the same text everywhere. Here each picture's text comes from its own row, so two pictures can carry different names, prices or entry numbers in one run.
My CSV has Windows paths like C:\shoots\IMG_014.JPG. Will they match?
Yes. Only the part after the last slash or backslash is compared, lower-cased, so the folder is ignored and IMG_014.JPG matches img_014.jpg.