verticle 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
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

verticle text

Post by troyd1 »

I have been trying all morning to create a scale. I am having trouble getting the verticle text to work correctly. Here is my command:
convert -size 400x400 xc:white -fill black -draw "line 10,10 50,10" -draw "rotate -90 text 25,25 'text'" test.jpg

Any help on this would be greatly appreciated.

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

Re: verticle text

Post by Bonzo »

Not quite sure what you are after Troy; are either of the texts on this page what you want ?
http://rubblewebs.co.uk/imagemagick/text.php
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Re: verticle text

Post by troyd1 »

I kind of want to do the lower left one with the text going up. What I am doing is building a percentage scale. The example was only that. I want to create a image that is 40 pixels high by 400 pixels wide. I am going to append this scale to the top of another image of the same size. I want to draw lines of varying length every 5 percent and label like 0, 25, 50, 75 and 100. I want the text to go up(verticle), but cannot get it to draw the text upwards (or downwards). I was just using the 400x400 for testing.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: verticle text

Post by Bonzo »

Something like this ?

Code: Select all

convert -size 40x400 xc:white -fill black -pointsize 8 -draw \"line 0,8 5,8\" -draw \" text 25,10 '5'\" -draw \"line 0,16 10,16\" -draw \" text 25,18 '10'\" -draw \"line 0,24 15,24\" -draw \" text 25,26 '15'\" -draw \"line 0,32 20,32\" -draw \" text 25,34 '20'\" scale.jpg

convert scale.jpg -rotate -90 scale1.jpg
How are you doing this ? If you are using php you could generate the code a lot easer than writting each line and number by hand.
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Re: verticle text

Post by troyd1 »

I will be building a command using a program to create it all based on the size dynamically. I did not want you to get wrapped up in the application, I can handle that. I was just wondering how to put text on an image at any angle using the draw command or other command. Like with a line you use starting and ending points. With text there is only a starting point so that you cannot tell it which direction to go. I thought maybe you would do that with the rotate command, but that seems to just rotate the image and not the text. I figured out that I can build the image vertically, put the text on it and rotate it at the end. It still would be nice to be able to say text x,y rotate degrees "enter the text" with x,y bing the anchor point.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: verticle text

Post by Bonzo »

You can rotate text with annotate http://www.imagemagick.org/script/comma ... p#annotate but I still do not think thats what you want ?

What did my example above look like compared to what you want ?
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Re: verticle text

Post by troyd1 »

This may get a little long, but here goes. I settled on using the annotate. It works how I want it to.
As a test I did:
convert -size 100x200 xc:white -fill black -draw "50,50 70,50" -fill blue -annotate 270x270+25+50 "test text"
This work great, the anchor point is the beginning of the text, but you can't do negative rotation.
I did get the draw command to work, but could not understand what it was doing. If you use center gravity, it rotates the text on the center of the page. This works great.

If you use no gravity or northwest(the default I believe) it does not rotate on a specific point that I can tell. Try the following, and please explain the results:
convert -size 100x200 xc:white -fill black -draw "50,50 70,50" -fill blue -draw "rotate 10 50,100 "this is test text"
This looks ok
When I start changing the rotate number to 20, 30, 45 or go negative, I get results that I canot figure out. The text does rotate, but moves off the page. I assumed it would rotate with an anchor point based on 50,100 from northwest.

As the annotate works, I am helped, but explaining this may save confusion in the future.

Thanks, Troy
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: verticle text

Post by anthony »

Note that no gravity and north-west gravity are not quite the same.
See IM Examples, Image Annotation
http://www.imagemagick.org/Usage/annota ... xt_gravity

The difference is that no gravity does not offset the image baseline for positioning purposes. All the other -gravity definations do offset the image to place the +0+0 position within the image proper.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply