Page 1 of 1
rendering antialiased text - variable size, transparency
Posted: 2008-08-21T13:58:30-07:00
by imagerakete
hey there,
i'm new to imagemagick and can't figure out how to achieve the following effect. maybe somebody can point me in the right direction!
i need to render text onto a transparent background. it needs to be antialised, and the size of the image should be determined by the content, rather than being fixed with something like -size 100x200. I also need to stroke the text with a white outline of 3-4 pixels.
i can get most of these effects happening, but not all at the same time! any ideas out there?
thanks in advance.
Re: rendering antialiased text - variable size, transparency
Posted: 2008-08-21T15:04:49-07:00
by fmw42
if you post your command line someone ought to be able to point out any problems.
When using label: (or caption:) you don't need to specify size
http://www.imagemagick.org/Usage/text/#label
Use -background none to get a transparent background
Draw a white stroke color and a dark fill color to get the outline you want. You can specify the strokewidth to make it 3-4 pixels wide.
Re: rendering antialiased text - variable size, transparency
Posted: 2008-08-22T00:21:58-07:00
by imagerakete
@fmw42 thanks for the input!
i guess my problem is that i don't know how to apply a stroke when label: ist set. here's the command that draws against a transparent bg *without* a stroke:
convert -background none -geometry +0+0 -fill \#bf0961 -pointsize 24 label:'Moo cow goes for a walk' -set label '' moo.png
and here's a command which does apply a stroke (mind the osx font location):
convert -size 320x100 xc:none -font /Library/Fonts/Arial.ttf -pointsize 24 -fill \#bf0961 -stroke white -strokewidth 6 -annotate +25+64.5 'Cow talk' -stroke none -annotate +25+65 'Cow talk' moo.png
problem with that is, i need a dynamic canvas size.
any ideas? i've tried out loads of combinations without cracking it.
Re: rendering antialiased text - variable size, transparency
Posted: 2008-08-22T09:33:15-07:00
by fmw42
what I have done often is use label first to get an image, then get its size, then go back and use annotate to redo it by creating a canvas of the same size and then using stroke and anything else more sophisticated than is allowed by label.
See my texteffects script at
http://www.fmwconcepts.com/imagemagick/index.html
Re: rendering antialiased text - variable size, transparency
Posted: 2008-08-24T16:28:33-07:00
by anthony
I explain label for size then use annotate technique in detail in IM examples
http://www.imagemagick.org/Usage/text/#size
Look at the 'Get Wet!' example.
Re: rendering antialiased text - variable size, transparency
Posted: 2008-08-28T08:44:44-07:00
by imagerakete
hey anthony,
thanks for pointing me at detailed information. i'm just trying to get to grips with the concepts involved, but running the get wet example produces the following error:
convert: unable to open image `tile_water.jpg': No such file or directory.
i pasted the command as is, using ImageMagick 6.4.1 08/05/08 Q16 on OSX.
any ideas what i'm doing wrong here? i'm finding it a bit difficult to get a grip on the syntax.
cheers!
Re: rendering antialiased text - variable size, transparency
Posted: 2008-08-28T17:54:53-07:00
by anthony
The images used as starting points in examples can be found in the IM Examples Images Directory
http://www.imagemagick.org/Usage/images/
OR you can just prefix the image with the URL of the Examples so IM knows to download it from the web site.
For that example...
Code: Select all
convert -font Ravie -pointsize 72 label:'Get Wet!' -border 10 \
-tile http://www.imagemagick.org/Usage/text/tile_aqua.jpg -draw "color 0,0 reset" \
-tile http://www.imagemagick.org/Usage/text/tile_water.jpg -gravity center -annotate +0+0 'Get Wet!' \
autosize_wet.jpg
You may also need to get the Ravie font (see top level page)
But it is better for you to just get it once yourself.
Code: Select all
convert http://www.imagemagick.org/Usage/text/tile_water.jpg tile_water.jpg
convert http://www.imagemagick.org/Usage/text/tile_aqua.jpg ile_aqua.jpg
This is actually equivelent to using 'wget' available on most systems)
Basically download the image, or substitute your own, as detailed on the top level page about source images and fonts.