Slow 'convert' on captions. And 1 more question.

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
BertyWooster
Posts: 3
Joined: 2011-08-31T13:16:09-07:00
Authentication code: 8675308

Slow 'convert' on captions. And 1 more question.

Post by BertyWooster »

Hello!

First of all. I need to create custom background for my images (~ 660x1000) - the repeating arbitrary text rotated at arbitrary angle. Also it would be nice to have gradient on this text (blue-red, from top to bottom, for example, but it's not case).

After reading manuals, I've decided to do the following:

1) Create "plain text" image, for example, 1200x2000;
2) Rotate it to custom angle.
3) Crop image with 660x1000 rectangle
4) And merge it with my "target" image.

But I bumped into problems at steps 1-2.

The command for these steps is (Windows):

convert -size 1200x2000 -font Arial -pointsize 20 -tile gradient:red-blue -size 1200x2000 ^
-fill blue caption:"@some.txt" -rotate 17 funfont_gradients.bmp

It tooks about 60 seconds to complete (windows XP, 3GB, 2.4GHz).

If I put "label" instead of "caption", it tooks just 3-4 seconds, but the result is just one string of text, which disappears at the right edge, of course :)
Also, if I put just 3-4 lines of text in "mytext.txt", it also works fine.

So it seems that problem in "caption" key.

What can I do?

And, maybe, there's another way to solve my problem? Again, I just need to obtain rotated text as a background. Here's the sample of background: http://diamantsoft.com/sample.jpg

Thanks in advance! And sorry for my English :( I know that it's not perfect...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Slow 'convert' on captions. And 1 more question.

Post by fmw42 »

convert -size 1200x2000 -font Arial -pointsize 20 -tile gradient:red-blue -size 1200x2000 ^
-fill blue caption:"@some.txt" -rotate 17 funfont_gradients.bmp
Your syntax is not fully correct. It gives me error message about files missing.

Try this inststead to reproduce your example


# first line sets up font and background
# second line uses label: to draw the text and saves it as an in-memory mpr file
# third line tiles that out to 1200x2000
# fourth line rotates the image and crops the center to 660x1000

convert -background white -font Arial -fill blue -pointsize 20 \
label:"sample of text" -write mpr:text +delete \
-size 1200x2000 tile:mpr:text \
-rotate 17 -gravity center -crop 660x1000+0+0 +repage result.png

On windows replace the line continuation \ with ^

see http://www.imagemagick.org/Usage/canvas/#tile_memory
BertyWooster
Posts: 3
Joined: 2011-08-31T13:16:09-07:00
Authentication code: 8675308

Re: Slow 'convert' on captions. And 1 more question.

Post by BertyWooster »

You the man!

Thanks to you example, I understood how things work :) I also studied myself, and replaced "label:" statement with a set of "draw" instructions, and got nice gradient through each line :)

Thanks again.
Post Reply