How do I use ImageMagick to create vertical text with Asian

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

How do I use ImageMagick to create vertical text with Asian

Post 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!
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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.
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

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

Post 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
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

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

Post 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
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
Post Reply