Text Update From CSV
Script for Adobe Photoshop
Latest update 8/22/2023, version 1.9
The script reads CSV spreadsheet rows for layer names and text, and updates matching layers in a template image, then saves new images of each result.
- Update text layers with new content
- Multiple text layers each with own content
- Save a unique image for each row of CSV
- Output JPG, PNG, TIF, or PSD
For multiple image and text layers, images from URLs, and unique output file names, see Variable Images From CSV. To process multiple templates and/or data files, and other advanced features, see Variable Images Advanced.
Before using the script
Using the script requires some preparation.
First is a template image that has text layers with specific names that will be referenced in the spreadsheet data.
Example template image
Dialog vector created by freepik - www.freepik.com
The template image requires at least one text layer. There may be additional text layers that are also updated, and there may be other layers or layer groups, of anything to include with all images output.
If the text content might span multiple lines, use a text area rather than single line to define the placeholder content of each text layer in the template image. More about the reason for this is explained in the section How text is positioned.
The second item to prepare is a spreadsheet of the layer names and text content, saved as Comma Separated Values (CSV format).
The spreadsheet must have at least three columns, one for “file name” (name given to each file saved), a second column for “layer” (name of the text layer to update), and a third column for “text”, the content to put into the layer. For additional text layers, add another two columns, again “layer” and “text” for the next layer’s name and content. Repeat another two columns for every layer to update. The script does not impose a limit on the number of text layers possible. The number is limited only by how many layers Photoshop can handle given the available computer resources. Any layer name in the data that does not exist in the template image is ignored. Likewise, any layers in the template image that are not listed in the data are also ignored, but their content is included with each image output.
Each row of the spreadsheet results in a copy of the template image saved with the specified text layers updated to their specified text, and named by the value in the column file name. This is the base name (name without extension). The Format option (described in the next section) determines which extension the script adds to the base name.
Dialog vector created by freepik - www.freepik.com
How to use the script
With the template image open, and CSV ready, run the script.
The interface has three sections: Data file, Options, and Output. Select the CSV file and the output folder. Enable the desired options, and click the OK button to begin. A progress bar is displayed as images are prepared and output.
For each image processed, each text layer name that matches a spreadsheet column layer has its content updated to the following text column value. The layer itself is not replaced, only the contents, to preserve any effects applied to the placeholder text.
Section 1: Data file (CSV)
Delimiter — the character that separates columns of the data file. The default is comma, normal in the United States. Some European countries use semicolon rather than comma. Select the delimiter used in your region of the world.
File — select the CSV data file.
Section 2: Options
Position text based on placeholder original position — when enabled, before replacing text content of each layer, the script records the position of the placeholder text. When the placeholder is a text area, the current paragraph alignment determines the ultimate text position. If alignment is left, new content aligns to the top-left anchor of the text area. Right, the top-right anchor. If alignment is center, new content is positioned so that its center matches the original center of the placeholder text area. The result is the text is not only center horizontally, but vertically as well, whether single or multiple lines.
When this option is disabled, the text contents are updated but the layer does not change position.
At this time, the replacement of text on a path is unreliable due to a bug in Photoshop that shifts the path position when altered by ExtendScript.
Section 3: Output
Folder — select the location to which images are output.
Format — select the file format to output. Choices are BMP, JPG, PNG, PSD, or TIF.
Convert to profile — converts color to the selected profile prior to output. Note that BMP and PNG formats are always converted to sRGB web standard, and the option to select otherwise is disabled.
TIP: Converting to another profile is primarily to make CMYK separations for print, which of course is functionality the script provides. But as well, this option can convert duotones to RGB or CMYK, or convert these and other color spaces to grayscale (use the profile Dot Gain 20%).
Flatten — result is a single “Background” layer. BMP and JPG always perform this step.
Quality — applies to JPEG images. Valid range is from 0 to 12. 0 is extreme compression resulting in low quality. 12 is light compression that is virtually indistinguishable from the original, the highest possible quality, which of course, results in the largest file size. 10 to 12 is recommended for print or other high-quality reproduction. For web images, 5 to 8 is an acceptable range.
Available color profiles
For the option Convert to profile, the list of profiles from which to choose is compiled by searching known locations in the system for .icc/.icm files and extracting the profile name. This occurs each time the script is launched. The list should include most of the same profiles Photoshop displays in dialogs such as Color Settings, but it doesn’t match exactly. If a needed profile does not appear in the list, add the profile to a location both Photoshop and the script look for profiles (below), and relaunch the script.
Text Update From CSV
Change log: text-update-from-csv.txt
For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.
IMPORTANT: scripts are developed for the latest Adobe Creative Cloud applications. Many scripts work in CC 2018 and later, even some as far back as CS6, but may not perform as expected, or run at all, when used in versions prior to 2018. Photoshop features Select Subject and Preserve Details 2.0 definitely fail prior to CC 2018 (version 19) as the features do not exist in earlier versions. For best results use the latest versions of Adobe Creative Cloud applications.
IMPORTANT: by downloading any of the scripts on this page you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.
IMPORTANT: fees paid for software products are the purchase of a non-exclusive license to use the software product and do not grant the purchaser any degree of ownership of the software code. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all software products regardless of the inspiration for the software product design or functionality.