Page 1 of 1

Right align text in area of image

Posted: 2009-09-21T03:26:46-07:00
by Sjors
Hi,

i'm struggling with this: i'm building a table-like image.
All goes well, but i can't get this to work: i want to place some text at x,y: 10,10, but want to right align it in an area of 40x40 (that area starting at 10,10).
Why? because they are numbers.
When i draw text it's ok to place it at 10,10; it will by default be placed at 10,10 and thus be left-aligned. But i have some numbers which i want to 'right-align'. The next 'column' starts at X position 55, so i want to reserve some kind of imaginary region from x=10 to x=50 (to keep some 5 px margin to the next column) and draw the text from right to left at 10,50.

I found the geometry and gravity option and the region, but my trial and errors didn't give me any good results.

Michel
so what i want to accomplish is this (in code because it gives me the right font :):

Code: Select all

aaaa    12345      bbbbb
aaaa      345      bbbbb
aaaa        5      bbbbb

and not this
aaaa    12345      bbbbb
aaaa    345        bbbbb
aaaa    5          bbbbb

Re: Right align text in area of image

Posted: 2009-09-21T16:37:32-07:00
by anthony
Best idea is to annotate the numbers into a 'column' image with gravity west.
When the column is complete you can then append columns, or overlay this column image onto the main image.


At this time IM does not make a distinction between using 'gravity' for placement,
and 'justification' (horizontally or vertically) of text and images at the position gravity determined. I have previously proposed that a 'justification' setting be created but have it default appropriately according to the current gravity setting when undefined.

This however has not been implemented. :-(


Note that while horizontal justification has 3 settings: left, center, right;
vertical justification would have 4: top, middle, baseline, bottom.
See http://www.imagemagick.org/Usage/bugs/f ... tification
for details of the proposal.

Re: Right align text in area of image

Posted: 2009-09-21T23:57:04-07:00
by Sjors
thanks very much for your reply.
Good to know i can stop searching the helpfiles :)