我有一个多语言网站,需要自动执行从 csv 源更新 psd 文件中文本图层的过程。
我知道由于宽度的变化,psp 中可能会出现故障,但无论如何,将文本放在文档中会有很大帮助。
我有什么选择?
EDIT:
Murmelschlurmel 有一个可行的解决方案。这是 Adobe 文档的链接。
http://livedocs.adobe.com/en_US/Photoshop/10.0/help.html?content=WSfd1234e1c4b69f30ea53e41001031ab64-740d.html http://livedocs.adobe.com/en_US/Photoshop/10.0/help.html?content=WSfd1234e1c4b69f30ea53e41001031ab64-740d.html
csv 文件的格式不太好:每个变量都需要一列。我希望每个变量都有一行。
它与元音变音(ä、ö 等)一起使用
EDIT 1:
另一个解决方案是使用 com 来自动化 Photoshop。如果您有几个需要更改文本的模板(按钮),那就太好了。这是我的 python 脚本,可能会让您入门。
您需要有一个包含以下列的 Excel 文件:
模板文件名、目标文件名、目标格式、文本
(即 template.psd、button1、gif、NiceButton)。
不使用工作表的第一行。
psp 模板只能有 1 个文本图层,并且不能有图层组。
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)