Page 1 of 1

Re: How to justify text in ImageMagick?

Posted: 2011-10-13T18:05:11-07:00
by fmw42
xerenader wrote:I'm just curious if there is any command line for justified text in IM.

I believe that -annotate respects the -gravity setting and -annotate +X+Y are relative to the gravity.

I believe that -draw also respects the -gravity setting.

see http://www.imagemagick.org/Usage/text/

Re: How to justify text in ImageMagick?

Posted: 2011-10-13T19:29:45-07:00
by anthony
Yes Gravity and Justification are currently the same thing in IMv6

One item on my IMv7 ToDo list, is to actually separate Gravity placement, verses Justification.
Not only for text, but also for placement of images during composition.

Justification is part of the SVG drawing, even though gravity is not.
It should be made part of MVG -draw settings as well.

Re: How to justify text in ImageMagick?

Posted: 2011-10-13T22:46:39-07:00
by anthony
Yes. but as gravity is involved it depends on exactly what you are trying to do.
So give us an example of what you actually want, and we'll be able to tell you more.

And look through the link already given above.

Re: How to justify text in ImageMagick?

Posted: 2011-10-14T01:17:39-07:00
by anthony
First I suggest you re-think the order of your operations.

-resample for example is an operator that works on an actual image! As such it at least should be AFTER the caption:

Also -density and -resample combination is not really required for caption, but for postscript pdf and other vector images. Text drawing is handles find without needing them.

The same goes for -rotate 0 which actually does nothing!

Simplifying the problem....

Code: Select all

   convert -gravity west -size 100x \
            caption:"This is a long sentance that should need word-wrapping" \
            text_caption.png
Image

Code: Select all

   convert -gravity east -size 100x \
            caption:"This is a long sentance that should need word-wrapping" \
            text_caption_east.png
Image

Code: Select all

   convert -gravity north -size 100x \
            caption:"This is a long sentance that should need word-wrapping" \
            text_caption_north.png
Image
Well that shows that the caption is handling the 'gravity' justification setting appropriately.

Vertically too if you 'fix' the optional height of the caption box size.