views:

362

answers:

1

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. 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 margin to the next column) and draw the text from right to left at 10,50.

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

Michel

+2  A: 

-gravity to the rescue, check the documentation with examples.

Update: OK I misunderstood the task.

But IMHO you can still create your numbers as an image first (of course you can customize the font, etc):

/usr/bin/convert -fill black -size 40x40 label:$NUMBERS -transparent white numbers.gif

Then trim the unnecessary parts:

/usr/bin/convert numbers.gif -trim trimmed.gif

Now check the new image's size

/usr/bin/identify trimmed.gif

Then calculate where to position it on your image. I leave it to you ;-)

Now you only need to merge the numbers to your image to the perfect position (replace +X+Y).

/usr/bin/composite -geometry +X+Y trimmed.gif original_image.jpg original_with_numbers.jpg

HTH

Zsolt Botykai
didn't mention it, but tried gravity too.All the examples are with a single image, say gravity -east for the entire image. I want to todo this in a PART of the image
Michel
can you please give me a code example?
Michel
Can you at least re-comment?
Michel
thanks, thought i was going nuts in the helpfiles
Michel