Creating an image with multi line 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
BassTeQ

Creating an image with multi line text

Post by BassTeQ »

Hi all, I'm currently creating some text images using the code below, but Id like to be able to have multiple lines of text, if I put a "\n" in my text string it doesnt seem to honor it.
How can I do this?

Code: Select all

convert.exe -size 2000x300 xc:grey30 -font Arial -pointsize 79 -gravity center -draw "fill grey70  text 0,0'this is my test text'" stamp_fgnd79.png
convert.exe -size 2000x300 xc:black -font Arial -pointsize 79 -gravity center -draw "fill white  text  1,1  'this is my test text'  text  0,0  'this is my test text' fill black  text -1,-1 'this is my test text'" +matte stamp_mask79.png
composite.exe -compose CopyOpacity  stamp_mask79.png  stamp_fgnd79.png  stamp79.png
Any help is greatly appreciated
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Creating an image with multi line text

Post by anthony »

-draw will not honor \n. Basically because SVG images will nto do so.

You need to use -annotate to get this and the % escapes in the string.
You can also create multi-line image with label: or eve word-wrapped images with caption:

see Annotate
http://www.imagemagick.org/Usage/#annotate
See multi-line labels
http://www.imagemagick.org/Usage/text/#label_lines

You may like to look at the new -interline-spacing option
http://www.imagemagick.org/Usage/text/# ... ne-spacing
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Creating an image with multi line text

Post by Bonzo »

Here are some tests I did a couple of years ago:
http://www.rubblewebs.co.uk/imagemagick/notes/wrap.php
BassTeQ

Re: Creating an image with multi line text

Post by BassTeQ »

Thanks for the replies, It's working as I need now!

Cheers
Post Reply