Page 1 of 1

Long Text in Image (with wordwrap)

Posted: 2007-04-01T14:01:33-07:00
by ali
hi, i have the problem, that imagemagick dont want to make a image with a text, that is 500 words long or so.

here is what i tried:
convert -background lightblue -fill blue -font test/fonts/font.ttf -size 820x600 caption:'Cum vero graeco interpretaris ut, ...' warp.jpg

imagemagick needs to automatically take the best fontsize, so that the text fill the image. but the programm gives me a "TokenLengthExceedsLimit" exception. well i know, why, the caption-parameter is too long, is there another way to do that what i want? what need i to do, to avoid that error? is there a solution for that?

thanks

Re: Long Text in Image (with wordwrap)

Posted: 2007-04-01T18:11:27-07:00
by anthony
For that length I'm suprized the command line works!

I suggest you feed the text into the command using a file

Code: Select all

   convert .... comment:@file_of_text.txt ....
or a pipeline

Code: Select all

   echo 'text to use" | convert .... comment:@- .... 

Re: Long Text in Image (with wordwrap)

Posted: 2007-04-06T10:22:13-07:00
by ali
ok thanks, that helped me, im using now pipes.

the (php-)projekt generates a big image with 2 boxes on a specific position. in that boxes must be a long text, with variable fontsize. i tried it with more pipes, but it seems to work only with max one pipe.

Code: Select all

convert xc:white -size 800x800 big.jpg
echo 'box1' | convert xc:grey -font xy -size 200x300 caption:@- muff:- | composite -geometry +150+50 - big.jpg big.jpg
echo 'box2' | convert xc:grey -font xy -size 200x300 caption:@- muff:- | composite -geometry +500+50 - big.jpg big.jpg
it would work with tempfiles, but tempfiles make it slower... is there a easy solution for my problem? has someone a better idea for a solution?
thanks

Re: Long Text in Image (with wordwrap)

Posted: 2007-04-07T05:33:12-07:00
by anthony
Specify the -size for the caption: but NOT the -pointsize. IM will resize the text to fit into the box with word wrapping..

See IM Examples Caption...
http://www.imagemagick.org/Usage/text/#caption

You can also set a centered justification using -gravity if you like.

Re: Long Text in Image (with wordwrap)

Posted: 2007-04-07T06:38:31-07:00
by ali
tanks but thats not my problem, i solved it, my problem are the two(!) pipes, with one pipe and tempfiles it works perfect, but i dont want use tempfiles. so my question was how to modify my lines there, so that it works with 2(!) pipes in one line...

tanks

Re: Long Text in Image (with wordwrap)

Posted: 2007-04-08T01:56:14-07:00
by anthony
Pipes are actually a shell scripting problem.

Try using a BASH shell script which can automaticaly create piped filenames.
That means you can do things like.

Code: Select all

   convert <( convert logo: gif:- ) <( convert rose: jpg:- )  -composite multi-pipe-image.gif
The <(...) executes the command and replaces it with a 'pipe file' which the outer command will read from (once only). Strange but it works, and you can use multiple times with multiple command and pipeline streams.

This is however SHELL command process handling, and not IM image handling.