Reputation: 23615
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
Upvotes: 3
Views: 3821
Reputation: 51603
-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) and trim it:
/usr/bin/convert -fill black -size 40x40 label:$NUMBERS -transparent white -trim numbers.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
Upvotes: 8