Photoshop Script: Automatically Generate Multiple Language Banner

Blake Lin
Akatsuki Taiwan Technology
2 min readApr 12, 2019

Intro

  • Designers need to create banners for multiple languages.
  • It takes lots of time and repeatedly and boring work.

Designer Work

  • Copy jp side PSD file and replace all the texts and images with Japanese
  • Find text in translation sheet and replace the right image and set visible or invisible for some layer

Use Photoshop script

  • Adobe provides scripting languages to manipulate photoshop objects.
  • Support: Apple Script, VB script, Javascript

https://www.adobe.com/devnet/photoshop/scripting.html

在Photoshop script中完成

  • 將美術常用的動作寫成function(ex: replace text, replace the image, add text, add image)
  • 可以將動作及其動作的參數以 JSON 格式傳入 script 中,並讀取並批次進行動作

Tips

  • Use Extend script toolkit to debug
  • This toolkit need enable in Preferences of Creative Cloud
  • To execute photoshop script in Mac shell, need use osascript to help

https://ss64.com/osx/osascript.html

in run.scpt
(use Adobe Photoshop CC 2019 to execute the main function with arguments in main.jsx )

on run argv
tell application “Adobe Photoshop CC 2019”
set UnixPath to POSIX path of ((path to me as text) & “::”)
set js to “#include ‘“ & UnixPath & “/main.jsx’;” & return
set js to js & “main(arguments);” & return
do javascript js with arguments argv
end tell
end run

in shell, run like

osascript ./run.scpt 'test.psd' '{"0":{"layer_name":"layer_1","layer_action":"modify_text","text":"Test\\nTest"},"1":{"layer_name":"layer_2","layer_action":"modify_text","text":"Test2\\nTest2"}}'
```
  • 再使用Excel作為批次動作及其動作的參數存放地點
  • 使用 ruby 做 parse excel 及執行 osascript ,以 parse的結果 以 json 格式帶入參數

就可以達成批次完成大量多語言 banner 的目的

--

--