How to wrap this text automatically using '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
donnied
Posts: 3
Joined: 2009-01-04T18:04:29-07:00

How to wrap this text automatically using 'text'

Post by donnied »

I am trying to create image files for various text. I would like it to auto wrap and it seems that I'll need to use caption and specify the size with only one dimension (1000x). Can I word wrap automatically using the text option?

Typically I would do:

Code: Select all

for ((i=1; i<=185; i++));do export b=${fsf3:0:$i};echo $b; convert -size 2000x500 xc:transparent -family Essays1743  -pointsize 42 -draw "text 65,100 '$b'" -channel RGBA -gaussian 0x6 -fill dodgerblue1 -stroke slategray4  -draw "text 50,100 '$b'" freedom3$i.png; done 
but I want to try to get the text to auto wrap so I tried using just one dimension but that created empty files:

Code: Select all

 for ((i=1; i<=185; i++));do export b=${fsf3:0:$i};echo $b; convert -size 1000x xc:transparent -family Essays1743  -pointsize 42 -draw "text 65,100 '$b'" -channel RGBA -gaussian 0x6 -fill dodgerblue1 -stroke slategray4  -draw "text 50,100 '$b'" free3$i.png; done 
?

If not I guess I'll have to go with 'caption' or 'label' which will be fine but I do like the shadow effect.

I also noticed that when I string the files together as an animated gif they run slow (e.g. -delay 0 produces a gif that moves at about the same speed as -delay 20).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to wrap this text automatically using 'text'

Post by anthony »

Only caption has word wrapping.

If you want to do it a different way then you will have to write a program to do it that way. sorry.

See IM Examples, Text to Image Handling, Caption for more info
http://www.imagemagick.org/Usage/text/#caption

NOTE: if you do not specify a pointsize IM will try to fit the largest text it can into the space (both width and height) specified.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
donnied
Posts: 3
Joined: 2009-01-04T18:04:29-07:00

Re: How to wrap this text automatically using 'text'

Post by donnied »

I decided to go with:

Code: Select all

for ((i=1; i<=64; i++));do export a=${intro:0:$i};echo $a; echo $a| convert -size 1024x -font Essays1743-BoldItalic  -pointsize 42  -channel RGBA -background transparent -fill dodgerblue1 -stroke slategray4 caption:@- intro$i.png; done
Thank you.
Post Reply