I have a multilanguage website and need automate the process of updating textlayers in psd-files from a csv-source.
I know that there might be glitches in the psp because of changed widths, but anyway it would help a lot to have the text inside the documents.
What are my options?
EDIT:
Murmelschlurmel has a working solution. Here is the link to the Adobe documentation.
The format of the csv-file is not so nice: you need a column for each variable. I would expect a row for each variable.
It works with Umlaut (ä, ö etc)
EDIT 1:
Another solution is to use com to automate Photoshop. Thats nice if you have a couple of templates (buttons) that need changed text. Here is my script in python that might get you startet.
You need to have an excel file with columns: TemplateFileName, TargetFileName, TargetFormat, Text (ie template.psd, button1 , gif , NiceButton) . The first row of the sheet is not used. The psp template should only have 1 textlayer and can not have layergroups.
import win32com.client
import xlrd
spreadsheet = xlrd.open_workbook("text_buttons.xls")
sheet = spreadsheet.sheet_by_index(0)
psApp = win32com.client.Dispatch("Photoshop.Application")
jpgSaveOptions = win32com.client.Dispatch("Photoshop.JPEGSaveOptions")
jpgSaveOptions.EmbedColorProfile = True
jpgSaveOptions.FormatOptions = 1
jpgSaveOptions.Matte = 1
jpgSaveOptions.Quality = 1
gifSaveOptions = win32com.client.Dispatch("Photoshop.GIFSaveOptions")
for rowIndex in range(sheet.nrows):
if(rowIndex > 0):
template = sheet.row(rowIndex)[0].value
targetFile = sheet.row(rowIndex)[1].value
targetFileFormat = sheet.row(rowIndex)[2].value
textTranslated = sheet.row(rowIndex)[3].value
psApp.Open(r"D:\Design\Produktion\%s" % template )
doc = psApp.Application.ActiveDocument
for layer in doc.Layers:
if (layer.Kind == 2):
layer.TextItem.Contents = textTranslated
if(targetFileFormat == "gif"):
doc.SaveAs(r"D:\Design\Produktion\de\%s" % targetFile, gifSaveOptions, True, 2)
if(targetFileFormat == "jpg"):
doc.SaveAs(r"D:\Design\Produktion\de\%s" % targetFile, jpgSaveOptions, True, 2)