Creating a multi layered psd file with "editable text" using command line - linux

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.

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:
tell application "Finder" to set thePath to (home as string) & "TestText.tif"
set thePosix to quoted form of POSIX path of thePath
display dialog thePosix
do shell script "touch " & thePosix
tell application "Adobe Photoshop CC"
activate
make new document with properties {name:"Testtextlayers"}
make new art layer at current document with properties {kind:text layer}
make new art layer at current document with properties {kind:text layer}
tell text object of art layer 1 of current document
set {contents, size, stroke color} to {"Hello", 30.0, {class:RGB hex color, hex value:"913b8e"}}
end tell
tell text object of art layer 2 of current document
set {contents, size, stroke color, position} to {"World", 48.0, {class:RGB hex color, hex value:"339966"}, {3, 4}}
end tell
set myOptions to {class:TIFF save options, image compression:none, byte order:Mac OS, save alpha channels:true, save spot colors:true, embed color profile:true}
save current document in file thePath as TIFF with options myOptions appending no extension without copying
end tell
The Extendscript version may be more portable across Linux and Windows.

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:
<text
xml:space="preserve"
style="font-size:40px;...font-family:Sans"
x="140"
y="123.79075"
id="text2999"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3001"
x="140"
y="123.79075">MyText here</tspan></text>
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:
python -c "import sys; open(sys.argv[2], 'wt').write(open(sys.argv[1]).read().format(*sys.argv[3:]) )" template.svg drawing.svg My other text file shines
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?)

Related

Is it possible to make Inkscape autotrace PNG to SVG, but from the command line?

I want to automate "raster to vector" conversions. PNG to SVG. (most Qs here on SO are the other way around)
I have tried the old command line tool autotrace on Linux, but I could not get it to run. I've tried to install a package, and to compile it from the source. Nope.
Then I've realised that Inkscape has "autotrace" now integrated in its codebase. I'd like to convert simple sketches from PNG to SVG.
And I want to do this in a Bash for-loop , with different autotrace settings (number of passes; ignore Speckles with max X pixels width) etc.
I've tried the "action" command-line option
inkscape --without-gui --actions="file-open:my.png"
and this brings up the small "png bitmap image import" dialog, waiting for me to confirm.
Also I've tried the verb command line option
inkscape --with-gui --verb="FileImport:my.png"
and this opens the large "Select file to import" dialog (ignoring my --verb argument)
At this point I gave up.
I want Inkscape to import a PNG picture, autotrace it with some settings, save it as SVG. Perhaps, beofre saving, duplicate the traced layer, lock the imported background layer, rename the layers from path-12345 to "tracesettings-x-y-z" etc.
(my final goal is to permute the tracing settings, to find good ones for my use-case, but that's not the focus of this question)
Inkscape is using potrace and autotrace to trace bitmap images into vector formats such as SVG and PDF.
Let's assume you have an image: foo.png that you want to trace to SVG using potrace:
First, you need to convert your image to a bitmap format (BMP).
Invoke the potrace command
# I am using ImageMagick convert command to convert PNG to BMP
convert foo.png foo.bmp
# Invoke potrace command with SVG backend
potrace -b svg foo.bmp
The result will be: foo.svg.

Absolute Positioning of Text in a Dynamically Sized SVG

I have an SVG graphic that I want to put some text on from my PHP variables. The graphic was generated in Illustrator and resizes in my web page to 100% width. Here is a representation of it:
How could this be done for the 8 text items? Does something special need to be done in Illustrator, like creating an anchor point for the text? How do I update the text item? I've done research but haven't been able to find a similar situation.
Thankful for any information that could help me narrow down my search.
Being someone who has never worked with files of .SVG file type before, this was a misunderstanding.
If you design a graphic in Adobe Illustrator, save it as an SVG and edit it with your favorite text editor, you will be able to see the SVG mark-up. It all makes sense now, and here you will be able to change the text at the code-level.
For my application, I saved the SVG as a PHP file and did an include on it, while changing the raw text to PHP variables in said file. This allowed me to pass my dynamic text as variables to the graphic.

Inkscape breaks graphic in input

I have a visio drawing where I need to write text inside the boxes.
When I save the visio drawing as a SVG the text which consists of multiple lines is overwritten on top of each other when previewed in Inkscape. Note the purple box.
Has anybody encountered this before, is there a solution?
EDIT: after trying multiple software I noticed that it is not Visio output to blame, but it is Inkscape input. Obviously it breaks the file when when it reads it.
Any solution?

how do i create a text on path?

i really want to know how to create texts in a background using corel draw 4, for example on some currencies and certificates, you may have, "Bank of Ghana, Bank of Ghana", written plenty in a wavy style with small sized fonts in the background or if its a school, you have the name of the school written plenty but small small font size in the background. Any help please??
How to Create Text on Path as per Example
Draw a path
Type Text
Example
Select Both Path and ext
Click Text from Menu and Click Fit Text to Path
Example
Finish
If you find my answer helpful please mark it, So others can take the benefits of it.
You can add any text along the path of an open object like line or a closed object like squre or circle.
Draw any path (cirlce, squre, lines)
Type Text
Type Text
With Pick tool , select a path.
Select Path
Click Text Fit text to path.
Text-> Fit to Path
You can also edit fit text to a path by clicking these icons.
Edit Setting

Flash CS5 - How to change anti-aliasing on all text containers in an animation

Is there a quick way to change all text containers so that the anti-alias setting is "Use Device Fonts"?
I am using Flash CS5, and need to convert about 300 animations, each with 20 or more text boxes, so that they use device fonts. This is necessary so that we can more easily display traditional Chinese characters.
I can go through each text box, change the font to _sans and it automatically switches to Use Device Font - then I don't need to embed the font files. So I tried to use the Find and Replace tool to change the font on all text boxes. It worked fine at changing the fonts, but it did not auto-switch the anti-alias. Any help on this would save hours of work.
Thanks.
Hopefully you're not too far into your work on this one, but there's a new development with CS5 that will help you with just this. It's called the .xfl format, and all .fla's are actually this format, but zipped up. Have a read here for more info: http://blog.theflashblog.com/?p=1986
What this means is you can convert your fla to xfl (or just change the suffix to .zip and unzip as the above article suggests), and do a Find&Replace on all text field font values.
Hope that helps!

Resources