views:

1708

answers:

2

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.

http://livedocs.adobe.com/en_US/Photoshop/10.0/help.html?content=WSfd1234e1c4b69f30ea53e41001031ab64-740d.html

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)
+1  A: 

It might be little bit off too much, but I have used Adobe AlterCast/Grphics server to handle exactly same issue.

Also if its just Text GIF/JPG image, you can use Python+PIL (Python Imaging Library). Here is a sample code (works on Windows OS with Arial and Osaka fonts installed.)

#!/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")
This sounded like the perfect solution. But the product is discontinued. (last name was Adobe Graphics Server - http://www.adobe.com/products/server/graphics/ ). Image processing is not feasible for me, because I nedd PSP - specific efects.
Malcolm Frexner
+2  A: 

You can use "Data Driven Design" to do this. There is also a concept of data driven design in computer science, but as far as I can see this is not not related to the use of the word in Photoshop.

Here is how to proceed:

Load your image in Photoshop and define your variables with Image > Variable > Define.

Then convert your csv to a format Photoshop can read. I had the best experiences with tab delimted text.

Finally load the text file in Photoshop with Images > Variables > Data Set and let Photoshop save all iterations.

When I tried this first, I found that the Photoshop help file didn't provide enough details. I searched the Internet for photoshop "data set" and found some good tutorials, e.g. this one from digitaltutors.

Murmelschlurmel