Question

J'ai un site multilangue et ont besoin d'automatiser le processus de mise à jour textlayers dans les fichiers Psd-csv à partir d'une source.

Je sais qu'il pourrait y avoir des failles dans les PSPGen en raison des largeurs modifiées, mais de toute façon, il serait très utile d'avoir le texte à l'intérieur des documents.

Quelles sont mes options?

EDIT:

Murmelschlurmel a une solution de travail. Voici le lien vers la documentation Adobe.

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

Le format du fichier csv est pas si agréable: vous avez besoin d'une colonne pour chaque variable. Je me attends à une ligne pour chaque variable.

Il fonctionne avec Umlaut (ä, ö, etc)

EDIT 1:

Une autre solution consiste à utiliser com pour automatiser Photoshop. Des thats bien si vous avez deux ou trois modèles (boutons) qui ont besoin de texte modifié. Voici mon script en python qui pourrait vous aider à startet.

Vous devez avoir un fichier Excel avec des colonnes: TemplateFileName, TargetFileName, TargetFormat, Texte (C.-à-template.psd, button1, gif, NiceButton). La première rangée de la feuille est pas utilisée. Le modèle ne devrait avoir PSPGen 1 TextLayer et ne peut pas avoir 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)

Autres conseils

Il est peut-être peu de trop, mais je l'ai utilisé serveur Adobe AlterCast / Grphics pour traiter exactement le même problème.

Aussi, si son texte juste l'image GIF / JPG, vous pouvez utiliser Python + PIL (Python Imaging Library). Voici un exemple de code (fonctionne sous Windows OS avec les polices Arial et Osaka installées.)

#!/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")
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top