Fred's ImageMagick Scripts


 

 

TEXTEFFECT


Converts text to an image after applying various effects, styling and color

Download Script

last modified: May 30, 2008



USAGE: texteffect -t "some text" [-f font] [-p pointsize] [-s style] [-e effect] [-i italic] [-l lineweight] [-d distortion] [-r rotation] [-x excess-area] [-t text-color] [-o outline-color] [-b background-color] [-u under-color] [-g glow-shadow-color] [-m smudge] [-w wavecycles] [-a arc] [infile] outfile
USAGE: texteffect [-h or -help]

-t .... "some text" ........... text to use; enclose in double quotes
-f .... font .................. fontname; use bold/italic font to make bold/italic;
............................... default=Arial
-p .... pointsize ............. pointsize for font; default=48
-s .... style ................. style=plain,outline,glow,softshadow,hardshadow,stamp,
............................... bevel,antibevel,gradient; default=plain
-e .... effect ................ effect=normal,arc-top,arc-bottom,arch-top,arch-bottom,
............................... bulge,bulge-top,bulge-bottom,concave,concave-top,concave-bottom,
............................... convex,convex-top,convex-bottom,pinch,pinch-top,pinch-bottom,
............................... wave-right,wedge-top-right,wedge-bottom-right,
............................... wedge-left,wedge-top-left,wedge-bottom-left; default=none
-i .... italic ................ italic slant angle in degrees; -45<=float<=45; default=0
-l .... lineweight ............ line thickness in pixels; float>0; default=1
-d .... distortion ............ distortion amount; 0<=float<=1; default=0.5
-r .... rotation .............. rotation angle; -180<=float<=180; default=0
-x .... excess-area ........... excess area or pad in pixels around outside of text; default=10
-c .... text-color ............ color of text; any IM color specification; default=skyblue
-o .... outline-color ......... color of outline; any IM color specification; default=black
-b .... background-color ...... color of background; any IM color specification; default=white;
............................... use none for transparent;
-u .... under-color ........... color under text; any IM color specification; default=none;
-g .... glow-shadow-color ..... color for glow or shadow; any IM color specification;
............................... default=outline-color;
-m .... smudge ................ spread for glow, softshadow, bevel, antibevel and stamp in pixels;
............................... float>=0; default=3
-w .... wave-cycles ........... number of wave cycles; float>0; default=1
-a .... angle ................. angle for arc or gradient; 0<=float<=360; default=0
infile ........................ if infile is provided, it represents a tile pattern image
............................... that will be used in place of the text color.

PURPOSE: To convert text to an image after applying various effects, styling and color.

DESCRIPTION: TEXTEFFECT convert text to an image after applying various effects, styling and color. Effects include: normal, arc-top, arc-bottom, arch-top, arch-bottom, bulge, bulge-top, bulge-bottom, concave, concave-top, concave-bottom, convex, convex-top, convex-bottom, pinch, pinch-top, pinch-bottom, wave-right, wedge-top-right, wedge-bottom-right, wedge-left, wedge-top-left and wedge-bottom-left. Styles include: plain, outline, glow, hardshadow, softshadow, bevel, antibevel, stamp and gradient.

ARGUMENTS:

-t "some text" ... The text to apply some effect, style and/or color and convert to an image. Required parameter. Be sure to enclose in double quotes.

-f font ... FONT is the desired font for the text. Use a bold/italics font if you want the text to be bold/italics or use the italic option. The default is Arial.

-p pointsize ... POINTSIZE is the desired pointsize for the font. The output image will be generated to the size consistent with this pointsize and any padding you apply. The default is 48.

-s style ... STYLE is the style of the text. The choices are plain, outline, glow and shadow. Plain is just colored text with no outline. Outline is text that has an outline or border around it of user specified thickness and presumably of a different color. Glow has an outline and a glow effect. Both shadows have an outline and a shadow effect (darkening) on the SouthEast side. You may make the outline color the same as the text or the same as the glow/shadow or even a different color. Stamp is similar to hardshadow, but has the darkening on the NorthWest side in order to make a stamped or indented effect. Bevel has brightening on the NorthWest and darkening on the SouthEast. Antibevel is the opposite with brightening on the SouthEast and darkening on the NorthWest. Bevel and antibevel allow both a line weight and smudge to soften the style. The gradient angle is controlled by the -a angle option. For angle=0, the gradient is darkest at the bottom and lightest at the top. As the angle increased, the gradient rotates clockwise. The gradient option also allows an outline. Plain, outline and gradient allow an undercolor. The others do not. The default is plain.

-i italic ... ITALIC is the font slant angle in degrees which creates an italic effect. Values are floats between -45 and 45. The default=0.

-e effect ... EFFECT is the geometric shapes/distortions to apply. The choices are: normal, arc-top, arc-bottom, arch-top, arch-bottom, bulge, bulge-top, bulge-bottom, concave, concave-top, concave-bottom, convex, convex-top, convex-bottom, pinch, pinch-top, pinch-bottom, wave-right, wedge-top-right, wedge-bottom-right, wedge-left, wedge-top-left and wedge-bottom-left.

-l lineweight ... LINEWEIGHT is the outline border thickness in pixels. Values may be floats greater than 0. Glow and shadow styles require lineweights of atleast 1. The default is 1 pixel.

-x excess-area ... EXCESS-AREA is the padding around the text. Padding will be background color. See below for background color. Excess-area (padding) is an integer greater than or equal to 0. The default is 10 pixels.

-c text-color ... TEXT-COLOR is the color to apply to the text. Any valid IM text color may be used. The default is skyblue. See http://imagemagick.org/script/color.php

-o outline-color ... OUTLINE-COLOR is the color to apply to the text border or outline. Any valid IM text color may be used. The default is black. See http://imagemagick.org/script/color.php

-b background-color ... BACKGROUND-COLOR is the color to apply to the background and padding if any. Any valid IM text color may be used. The default is white. Use none for transparent background. See http://imagemagick.org/script/color.php

-u under-color ... UNDER-COLOR is the color to apply directly under the text, but separate from the background/padding. Any valid IM text color may be used. The default is none. See http://imagemagick.org/script/color.php

-g glow-shadow-color ... GLOW-SHADOW-COLOR is the color to apply to generate a glow or shadow effect. For shadow this is typically black. Any valid IM text color may be used. The default is the outline-color. See http://imagemagick.org/script/color.php

-m smudge ... SMUDGE is the spreading amount or distance for the glow, softshadow, bevel, antibevel and stamp. It is specified in pixels as a float greater than or equal to 0. The default is 3.

-w wave-cycles ... WAVE-CYCLES is the number of cycles for the wave effect. Values are floats greater than zero. The default=1 (one up and down wave cycle)

-a arc ... ARC is the arc amount in degrees. Values must be greater than 0 and less than or equal to 360. The default=60.

IMPORTANT: Please note that you can use only one instance of each argument. For example, you cannot have multiple styles (-s style) in the same command line, except as noted where some styles allow you to have an outline also, such as glow. But in those cases the outline is controlled by the -o outline-color and -l lineweight arguments.

NOTE: See http://www.imagemagick.org/Usage/text/ and http://www.imagemagick.org/Usage/fonts/ for more examples and detailed explanations of how many of these styles were created.

NOTE: Some effects require the use of -fx and thus will be slower than the others. These include: the variations on bulge, concave, convex and pinch.

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.


EXAMPLES


Example Text Effects

 

Plain Normal Text
Arguments:
-t "SOME PLAIN TEXT" -s plain -e normal -f Arial -p 48 -c royalblue -b white

 

Plain Normal Text
Arguments:
-t "SOME PLAIN TEXT" -s plain -e normal -f Arial -p 48 -c royalblue -b white -u lightpink

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -u none

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b white -o black -l 3 -u none

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b white -o black -l 10 -u none

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b none -o black -l 1 -u none
(composited onto a checkerboard background)

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b skyblue -o black -l 1 -u skyblue

 

Outline Normal Text
Arguments:
-t "SOME OUTLINE TEXT" -s outline -e normal -f Arial -p 48 -i 20 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Normal Text
Arguments:
-t "SOME TILED TEXT" -s outline -e normal -f Arial -p 48 -b white -o black -l 1 -u none tile_disks.jpg

 

Outline Normal Text
Arguments:
-t "SOME GLITTER TEXT" -s outline -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

Then Postprocess to make skyblue into transparent and add tiled blue glitter image in its place:

convert \
\( SOMEGLITTERTEXT_Arial_normal_outline_d0p5_skyblue_uc_lightpink_lwt1_pt48.png -fuzz 20% -transparent skyblue \) \
null: \( tile_glitter_blue.gif -virtual-pixel tile -set option:distort:viewport $dim -distort SRT 0 \) \
-compose DstOver -layers composite \
-loop 0 -layers Optimize SOMEGLITTERTEXT_Arial_normal_outline_uc_lightpink_lwt1_pt48.gif
Start With:

Then make skyblue into transparent and add tiled glitter image

 

Gradient Normal Text
Arguments:
-t "SOME GRADIENT TEXT" -s gradient -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -u none -a 0

 

Gradient Normal Text
Arguments:
-t "SOME GRADIENT TEXT" -s gradient -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -u none -a 180

 

Gradient Normal Text
Arguments:
-t "SOME GRADIENT TEXT" -s gradient -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -u none -a 90

 

Glow Normal Text
Arguments:
-t "SOME GLOW TEXT" -s glow -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -g blue -m 10

 

Glow Normal Text
Arguments:
-t "SOME GLOW TEXT" -s glow -e normal -f Arial -p 48 -c skyblue -b white -o blue -l 1 -g blue -m 10

 

Glow Normal Text
Arguments:
-t "SOME GLOW TEXT" -s glow -e normal -f Arial -p 48 -c skyblue -b white -o skyblue -l 1 -g blue -m 10

 

Softshadow Normal Text
Arguments:
-t "SOME SOFT SHADOW TEXT" -s softshadow -e normal -f Arial -p 48 -c skyblue -b white -o black -l 1 -g black -m 10

 

Softshadow Normal Text
Arguments:
-t "SOME SOFT SHADOW TEXT" -s softshadow -e normal -f Arial -p 48 -c skyblue -b white -o skyblue -l 1 -g black -m 10

 

Softshadow Normal Text
Arguments:
-t "SOME SOFT SHADOW TEXT" -s softshadow -e normal -f Arial -p 48 -c skyblue -b white -o none -l 1 -g black -m 10

 

Hardshadow Normal Text
Arguments:
-t "SOME HARD SHADOW TEXT" -s hardshadow -e normal -f Arial -p 48 -c skyblue -b white -l 1 -g black

 

Hardshadow Normal Text
Arguments:
-t "SOME HARD SHADOW TEXT" -s hardshadow -e normal -f Arial -p 48 -c skyblue -b white -l 3 -g black

 

Stamp Normal Text
Arguments:
-t "SOME STAMP TEXT" -s stamp -e normal -f Arial -p 48 -c skyblue -b white -l 1 -m 0

 

Stamp Normal Text
Arguments:
-t "SOME STAMP TEXT" -s stamp -e normal -f Arial -p 48 -c skyblue -b white -l 2 -m 0

 

Bevel Normal Text
Arguments:
-t "SOME BEVEL TEXT" -s bevel -e normal -f Arial -p 48 -c skyblue -b lightpink -l 1 -m 0

 

Bevel Normal Text
Arguments:
-t "SOME BEVEL TEXT" -s bevel -e normal -f Arial -p 48 -c skyblue -b lightpink -l 1 -m 3

 

Bevel Normal Text
Arguments:
-t "SOME BEVEL TEXT" -s bevel -e normal -f Arial -p 48 -c skyblue -b lightpink -l 2 -m 3

 

Bevel Normal Text
Arguments:
-t "SOME BEVEL TEXT" -s bevel -e normal -f Arial -p 48 -c skyblue -b skyblue -l 1 -m 0

 

Bevel Normal Text
Arguments:
-t "SOME BEVEL TEXT" -s bevel -e normal -f Arial -p 48 -c skyblue -b skyblue -l 2 -m 3

 

Antibevel Normal Text
Arguments:
-t "SOME ANTIBEVEL TEXT" -s antibevel -e normal -f Arial -p 48 -c skyblue -b lightpink -l 1 -m 0

 

Antibevel Normal Text
Arguments:
-t "SOME ANTIBEVEL TEXT" -s antibevel -e normal -f Arial -p 48 -c skyblue -b lightpink -l 1 -m 3

 

Antibevel Normal Text
Arguments:
-t "SOME ANTIBEVEL TEXT" -s antibevel -e normal -f Arial -p 48 -c skyblue -b lightpink -l 2 -m 3

 

Outline Arc-Top Text
Arguments:
-t "SOME ARCTOP TEXT" -s outline -e arc-top -a 60 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arc-Top Text
Arguments:
-t "SOME ARCTOP TEXT" -s outline -e arc-top -a 180 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arc-Bottom Text
Arguments:
-t "SOME ARCBOTTOM TEXT" -s outline -e arc-bottom -a 60 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arc-Bottom Text
Arguments:
-t "SOME ARCBOTTOM TEXT" -s outline -e arc-bottom -a 180 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arch-Top Text
Arguments:
-t "SOME ARCHTOP TEXT" -s outline -e arch-top -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arch-Top Text
Arguments:
-t "SOME ARCHTOP TEXT" -s outline -e arch-top -d 1.0 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arch-Bottom Text
Arguments:
-t "SOME ARCHBOTTOM TEXT" -s outline -e arch-bottom -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Arch-Bottom Text
Arguments:
-t "SOME ARCHBOTTOM TEXT" -s outline -e arch-bottom -d 1.0 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Bulge Text
Arguments:
-t "SOME BULGE TEXT" -s outline -e bulge -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Bulge-Top Text
Arguments:
-t "SOME BULGETOP TEXT" -s outline -e bulge-top -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Bulge-Bottom Text
Arguments:
-t "SOME BULGEBOTTOM TEXT" -s outline -e bulge-bottom -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Concave Text
Arguments:
-t "SOME CONCAVE TEXT" -s outline -e concave -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Concave-Top Text
Arguments:
-t "SOME CONCAVETOP TEXT" -s outline -e concave-top -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Concave-Bottom Text
Arguments:
-t "SOME CONCAVEBOTTOM TEXT" -s outline -e concave-bottom -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Concave Text
Arguments:
-t "SOME CONVEX TEXT" -s outline -e convex -d 0.35 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Concave-Top Text
Arguments:
-t "SOME CONVEXTOP TEXT" -s outline -e convex-top -d 0.35 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Convex-Bottom Text
Arguments:
-t "SOME CONVEXBOTTOM TEXT" -s outline -e convex-bottom -d 0.35 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Pinch Text
Arguments:
-t "SOME PINCH TEXT" -s outline -e pinch -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Pinch-Top Text
Arguments:
-t "SOME PINCHTOP TEXT" -s outline -e pinch-top -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Pinch-Bottom Text
Arguments:
-t "SOME PINCHBOTTOM TEXT" -s outline -e pinch-bottom -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wave-Top Text
Arguments:
-t "SOME WAVETOP TEXT" -s outline -e wave-top -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wave-Bottom Text
Arguments:
-t "SOME WAVEBOTTOM TEXT" -s outline -e wave-bottom -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wedge-Left Text
Arguments:
-t "SOME WEDGELEFT TEXT" -s outline -e wedge-left -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wedge-Top-Left Text
Arguments:
-t "SOME WEDGETOPLEFT TEXT" -s outline -e wedge-top-left -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wedge-Bottom-Left Text
Arguments:
-t "SOME WEDGEBOTTOMLEFT TEXT" -s outline -e wedge-bottom-left -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wedge-Right Text
Arguments:
-t "SOME WEDGERIGHT TEXT" -s outline -e wedge-right -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wedge-Top-Right Text
Arguments:
-t "SOME WEDGETOPRIGHT TEXT" -s outline -e wedge-top-right -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink

 

Outline Wedge-Bottom-Right Text
Arguments:
-t "SOME WEDGEBOTTOMRIGHT TEXT" -s outline -e wedge-bottom-right -d 0.5 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink


What the script does is as follows:

  • Determines the output size by drawing the text once and trimming
  • Creates an image from the text with the specified font, pointsize, style and colors
  • Distorts the image according to the desired effect

This is equivalent to the following IM commands for the case of arc-top 60 degrees,
Arial font, pointsize 48, text color skyblue, outline color black, background color
white under color lightpink, line weight 1 and text of "SOME TEXT":

  • convert -background white \
    -fill skyblue -strokewidth 1 -stroke black \
    -font Arial -pointsize 48 \
    -gravity center label:"SOME TEXT" \
    -trim -bordercolor white -border 10 +repage $tmp0
    wd=`identify -format %w $tmp0`
    ht=`identify -format %h $tmp0`
    dim="${wd}x${ht}"
  • convert -size $dim xc:white -fill skyblue \
    -strokewidth 1 -stroke black -undercolor lightpink \
    -font Arial -pointsize 48 \
    -gravity center -draw "text 0,0 'SOME TEXT'" \
    -trim -bordercolor white -border 1 +repage $tmp0
  • convert $tmp0 -virtual-pixel background -background white \
    -distort arc "60,0" \
    -background white -trim -bordercolor white -border 10 $outfile