我有一个多语言网站,需要自动更新来自csv-source的psd文件中的文本层的过程。
我知道psp中可能存在毛刺,因为宽度发生了变化,但无论如何,在文档中包含文本会有很多帮助。
我有什么选择?
编辑:
Murmelschlurmel有一个可行的解决方案。以下是Adobe文档的链接。
csv文件的格式不太好:每个变量都需要一个列。我希望每个变量都有一行。
适用于Umlaut(ä,ö等)
编辑1:
另一个解决方案是使用com来自动化Photoshop。如果您有一些需要更改文本的模板(按钮),那太好了。这是我在python中的脚本,可能会让你开始。
您需要一个包含列的Excel文件: TemplateFileName,TargetFileName,TargetFormat,Text (即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)
答案 0 :(得分:22)
您可以使用“数据驱动设计”来执行此操作。计算机科学中也有data driven design的概念,但据我所知,这与Photoshop中单词的使用无关。
以下是如何继续:
在Photoshop中加载图像并使用图像>定义变量变量>定义强>
然后将您的csv转换为Photoshop可以阅读的格式。我使用制表符分隔文字获得了最佳体验。
最后使用图像>在Photoshop中加载文本文件变量>数据集,让Photoshop保存所有迭代。
当我第一次尝试这个时,我发现Photoshop帮助文件没有提供足够的细节。我在互联网上搜索 photoshop“数据集”并找到了一些很好的教程,例如这个来自digitaltutors。
答案 1 :(得分:1)
它可能有点过多,但我使用Adobe AlterCast / Grphics服务器来处理完全相同的问题。
另外,如果它只是Text GIF / JPG图像,则可以使用Python + PIL(Python Imaging Library)。 这是一个示例代码(适用于安装了Arial和Osaka字体的Windows操作系统。)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import ImageFont, ImageDraw, Image
#font = ImageFont.truetype("/usr/share/fonts/bitstream-vera/Vera.ttf", 24)
#font = ImageFont.truetype("futuratm.ttf", 18)
font = ImageFont.truetype("arial.ttf", 18)
im = Image.new("RGB", (365,20), "#fff")
draw = ImageDraw.Draw(im)
draw.text((0, 0), "Test Images", font=font, fill="#000")
im.save("TestImg_EN.gif", "GIF")
font = ImageFont.truetype("osaka.ttf", 18)
im = Image.new("RGB", (365,20), "#fff")
draw = ImageDraw.Draw(im)
draw.text((0, 0), u"テストイメージ", font=font, fill="#000")
im.save("TestImg_JP.gif", "GIF")