Editing Photoshop PSD text layers programmatically

EvanK picture EvanK · May 12, 2009 · Viewed 14.1k times · Source

I have a multi-layered PSD, with one specific layer being non-rasterized text. I'm trying to figure out a way I can, from a bash/perl/python/whatever-else program:

  1. load the PSD
  2. edit the text in said layer
  3. flatten all layers in the image
  4. save as a web-friendly format like PNG or JPG

I immediately thought of ImageMagick, but I don't think I can edit the text layer through IM. If I can accomplish the first two steps some other programmatic way, I can always use ImageMagick to perform the last two steps.

After a couple of hours of googling and searching CPAN and PyPI, I still have found nothing promising. Does anyone have advice or ideas on the subject?

Answer

wr. picture wr. · May 12, 2009

If you don't like to use the officially supported AppleScript, JavaScript, or VBScript, then there is also the possibility to do it in Python. This is explained in the article Photoshop scripting with Python, which relies on Photoshop's COM interface.

I have not tried it, so in case it does not work for you: If your text is preserved after conversion to SVG then you can simply replace it by whatever tool you like. Afterwards, convert it to PNG (eg. by inkscape --export-png=...).