I am trying to create a PSD file using command line (linux/osx).
Example:
I have 5 blocks of text
“hello”
“this”
“is”
“an”
“example”
I need a way to take these 5 blocks of text and generate a psd that will have 5 different layers for each text block and i need them to be editable after the psd has been generated and opened in photoshop.
Are you guys familiar with any software that can do this?
I tried GIMP and ImageMagick and i was able to generate a psd with 5 layers with the text blocks in there but unfortunately imageMagick seems to turn the text into an actual image so this makes the text non editable once opened up in photoshop.
2
Answers
Indeed – most software able to manipulate PSD images can only work with a subset of it. GIMP itself will only open text PSD layers as pixels.
My hint for your workflow would be to script this from inside photoshop, and create another kind of file, with text-markup, that would be rendered there. Doing that would not be possible through the command line, though –
(maybe it could be automated with GUI automation tools).
Ah – it just hit me – maybe you could work with the SVG file format, and have it converted to PSD later (the conversion would still require manual interaction inside Photoshop though – but maybe the SVG file is close enough you can ship it directly to your final users, isntead of a PSD)
As for an SVG approach: create a new template file in Inskcape, and possition
your 5 blocks of text wherever you like. The final result will contain your text in XML blocks looking like this:
Replace the actual text (
My text here
) whtih a markup such as {}, and then you can create your svg files with a python oneliner such as:The advantage of this approach is that you can actually style and format the template in very detailed ways. (hmm..browsing around, it looks like photoshop can’t simply open SVG files…too bad anyway – maybe you can swithch your needed workflow away from it?)
You can use Applescript or Extendscript to script Photoshop itself – there is a guide available here.
You can do something like this using the Applescript version:
The Extendscript version may be more portable across Linux and Windows.