Page 1 of 1

How do I use ImageMagick to create vertical text with Asian

Posted: 2013-03-22T23:30:09-07:00
by robocop
Hi there!

I am trying to get Asian characters to appear vertically centered.
Here's an example of what I'm after: http://www.freeimagehosting.net/lcg39

I am using the following command line code to generate the image with text. It comes out fine, but it is appearing horizontally.

Code: Select all

convert -font kaisho.ttf -pointsize 280  label:"マルコム"  -border 10 -tile templates/bg.jpg -draw "color 0,0 reset" -tile templates/text-color.jpg -gravity center -annotate +0+0 "マルコム" sample.jpg
I'm new to Imagemagick and searched the forums with not much luck. If someone could help me, I'd very much appreciate it :)

Thank you!

Re: How do I use ImageMagick to create vertical text with As

Posted: 2013-03-23T07:31:58-07:00
by fmw42

Re: How do I use ImageMagick to create vertical text with As

Posted: 2013-03-23T07:50:32-07:00
by Bonzo
Here is a little bit of php code I wrote:

Code: Select all

<?php
// With this code you can automaticaly add the \n to every character in the string.
// The last character will not have a \n 
// You could use a form to set the $string value

$string="TEXT"; 
 for ($pos = 0; $pos < strlen($string); $pos++) 
 if ( $pos != strlen($string)-1 ){ 
    $modified .= substr($string, $pos, 1)."\\n"; } 
         
    else $modified .= substr($string, $pos, 1); 
         
exec("convert -pointsize 20 -gravity center label:$modified label_vertical1.gif");
  ?> 
I have done a similar thing using images of the letters and -append

I think you could do it with Pango which can be used with later versions of Imagemagick on a Linux platform.
Pango usage.

Re: How do I use ImageMagick to create vertical text with As

Posted: 2013-03-30T22:43:30-07:00
by robocop
fmw42 wrote:try a new line character \n between each of your characters

see
http://www.imagemagick.org/Usage/text/#label_vertical
http://www.imagemagick.org/Usage/text/#user_escapes

Thanks very much for your help! This did the trick. Cheers

Re: How do I use ImageMagick to create vertical text with As

Posted: 2013-03-30T22:46:52-07:00
by robocop
Bonzo wrote:Here is a little bit of php code I wrote:

Code: Select all

<?php
// With this code you can automaticaly add the \n to every character in the string.
// The last character will not have a \n 
// You could use a form to set the $string value

$string="TEXT"; 
 for ($pos = 0; $pos < strlen($string); $pos++) 
 if ( $pos != strlen($string)-1 ){ 
    $modified .= substr($string, $pos, 1)."\\n"; } 
         
    else $modified .= substr($string, $pos, 1); 
         
exec("convert -pointsize 20 -gravity center label:$modified label_vertical1.gif");
  ?> 
I have done a similar thing using images of the letters and -append

I think you could do it with Pango which can be used with later versions of Imagemagick on a Linux platform.
Pango usage.
Hi Bonzo, Thanks a lot for the code and pointing me to Pango, it's very helpful. Cheers