vertical text

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
dsl
Posts: 21
Joined: 2008-01-22T15:14:29-07:00

vertical text

Post by dsl »

Hello!

please, help me to find out how annotation works.
I need to write text vertically. I just write text in a usual way using "\n", like "A\nB\nC\n".
The problem is how to control vertical distance between the characters.
Something similar to line-height in HTML.
Could you please suggest me anything?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: vertical text

Post by Bonzo »

I belive the spacing between the characters will be set by the font.

I wrote some code before putting the characters into a sized canvas:
Image

Code: Select all

<?php
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"R\" \" R.gif");
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"u\" \" u.gif");
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"b\" \" b.gif");
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"l\" \" l.gif");
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"e\" \" e.gif");
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"w\" \" w.gif");
exec("convert -size 20x20 xc:white -fill black -pointsize 20 -gravity center \\
-draw \" text 0,0 \"s\" \" s.gif");
exec("convert -background none -gravity Center \\
R.gif u.gif b.gif b.gif l.gif e.gif w.gif e.gif b.gif s.gif -append text_vertical.gif");

// Delete the tempory images 
$delete = array('R.gif','u.gif','b.gif','l.gif','e.gif','w.gif','s.gif'); 
foreach ($delete as $value) { 
    unlink($value); }
?> 

Another method :

<?php
 
 $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");

//With this code you can automaticaly add the \n to every character in the string.
//The last character will not have a \n 
?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: vertical text

Post by fmw42 »

IM does not have interline spacing at this time to my knowledge. I will defer to the IM folks to correct me. So the best you can do is use \n as many times as you want between characters. Not very good solution but I think that is all there is.

see
http://www.imagemagick.org/Usage/text/#label_vertical
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: vertical text

Post by magick »

We added an -interline-spacing option in the Subversion trunk, available by sometime tomorrow.
dsl
Posts: 21
Joined: 2008-01-22T15:14:29-07:00

Re: vertical text

Post by dsl »

Many thanks! I wonder, that nobody needs it before
But I have framework on Perl and use perl-magick. Is it possible to add "-interline-spacing" as a parameter to Annotate function?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: vertical text

Post by magick »

Already done. Grab ImageMagick-6.5.5-8 Beta sometime tomorrow.
dsl
Posts: 21
Joined: 2008-01-22T15:14:29-07:00

Re: vertical text

Post by dsl »

I just made
#svn co https://www.imagemagick.org/subversion/ ... gick/trunk ImageMagick

The last record in ChangeLog was made on 2009-08-31 for version 6.5.5-6
Is ChangeLog not up-to-date?
Also, how do you think, is it safe to roll out 6.5.5-8 on production server?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: vertical text

Post by magick »

6.5.5-8 will be released as a production release later today.
cotcot

Re: vertical text

Post by cotcot »

Great ! Thanks for adding -interline-spacing. I was just looking after it.
I compiled 6.5.5-9 and it works fine.
Post Reply