Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

3DTEXT


Converts text into an image with a 3D extrusion effect

Download Script

last modified: January 29, 2015



USAGE: 3Dtext -t "some text" [-f fontname] [-p pointsize] [-i italic] [-c text-color] [-u under-color] [-b border-color] [-o outline-color] [-l lineweight] [x extrude-color] [-a amount] [-d direction] outfile
USAGE: 3Dtext [-h or -help]

-t .... "some text" ....... text to use; enclose in double quotes
-f .... fontname .......... fontname; use bold/italic font to make bold/italic;
........................... default=Arial
-p .... pointsize ......... pointsize for font; integer>0; default=48
-i .... italic ............ italic slant angle in degrees; -45<=float<=45; default=0
-c .... text-color ........ color of text; any IM color specification; default=navy
-u .... under-color ....... color under text; any IM color specification; default=white;
-b .... border-color ...... color of border; any IM color specification; default=white;
-s .... border-size ....... size of border in pixels; integer>=0; default=5
-o .... outline-color ..... color of outline; any IM color specification; default=black
-l .... lineweight ........ line thickness for outline in pixels; float>=0; default=0
-x .... extrude-color ..... color of 3D extrusion effect; any IM color specification;
........................... default=gray
-a .... amount ............ 3D extrude amount in pixels; integer>0; default=8
-d .... direction ......... 3D extrude direction; northwest, north, northeast, east,
........................... southeast, south, southwest, west; default=northwest

PURPOSE: To convert text into an image with a 3D extrusion effect.

DESCRIPTION: 3DTEXT converts text into an image with a 3D extrusion effect. The use can control various colors and the extrusion amount and direction.

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 fontname ... FONTNAME 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.

-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.

-c text-color ... TEXT-COLOR is the color to apply to the text. Any valid IM text color may be used. The default is navy. 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 border padding. Any valid IM text color may be used. The default is white. See http://imagemagick.org/script/color.php

-b border-color ... BORDER-COLOR is the color to apply to the border padding. Any valid IM text color may be used. The default is white. See http://imagemagick.org/script/color.php

-s border-size ... BORDER-SIZE is the amount of border padding in pixels. The default=5

-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

-l lineweight ... LINEWEIGHT is the outline thickness in pixels. Values may be floats greater than or equal to 0. The default=0, indicates no outline.

-x extrude-color ... EXTRUDE-COLOR is the color to apply to the extrusion 3D effect. Any valid IM text color may be used. The default is gray. Use a very light or very dark gray (or color), depending upon direction to simulate shade-like lighting. See http://imagemagick.org/script/color.php

-a amount ... AMOUNT is the extrude amount to use to create the 3D effect. Values are integers>0. The default=8.

-d direction ... DIRECTION is the extrude direction to use to create the 3D effect. Choices are: northwest, north, northeast, east, southeast, south, southwest, west. The default=northwest.

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


Extrude Directions

 

Northwest
Arguments:
-t "Analog" -f Candice -p 72 -d northwest

 

North
Arguments:
-t "Analog" -f Candice -p 72 -d north

 

Northeast
Arguments:
-t "Analog" -f Candice -p 72 -d northeast

 

East
Arguments:
-t "Analog" -f Candice -p 72 -d east

 

Southeast
Arguments:
-t "Analog" -f Candice -p 72 -d southeast

 

South
Arguments:
-t "Analog" -f Candice -p 72 -d south

 

Southwest
Arguments:
-t "Analog" -f Candice -p 72 -d southwest

 

West
Arguments:
-t "Analog" -f Candice -p 72 -d west

 



Other Various Examples

 

Arguments:
-t "Extruded Text" -f Candice -p 72 -c skyblue -u pink -b white -s 5 -o purple1 -l 1 -x navy -a 8 -d northwest

 

Arguments:
-t "Extruded Text" -f Arial -p 72 -i 10 -c skyblue -u pink -b white -s 5 -o purple1 -l 1 -x navy -a 8 -d northwest

 

Arguments:
-t "Analog" -f Candice -u red -b skyblue -x gray90 -d southeast

 



What the script does is as follows:

  • Determines the output size by drawing the text once using label:
    and pads by 3 times the extrude amount
  • Creates an image from the text using -annotate with the specified font,
    pointsize and extrude color
  • Shifts the position by 1 pixel in the desired direction and redraws
  • Repeats a number of times equal to the extrude amount
  • Repeats one final time with the desired final colors

This is equivalent to the following IM commands for direction northwest:

  • pad=`expr 3 \* $xamt`
  • dim=`convert -background $ucolor -font $fontname -pointsize $psize \
    label:"$text" -trim -bordercolor $bcolor -border "$pad" +repage \
    -format "%wx%h" info:`
  • xx=$xamt
  • yy=$xamt
  • i=0
  • txtcmd=""
  • while [ $i -lt $xamt ]; do
  • txtcmd="$txtcmd -fill $xcolor -gravity center -annotate 0x$italic+$xx+$yy '$text'"
  • xx=`expr $xx - 1`
  • yy=`expr $yy - 1`
  • i=`expr $i + 1`
  • done
  • eval 'convert -size "$dim" xc:"$ucolor" \
    -font "$fontname" -pointsize "$psize" \
    '"$txtcmd"' \
    -fill "$tcolor" -strokewidth "$linewt" -stroke "$ocolor" \
    -gravity center -annotate 0x$italic+$xx+$yy "$text" \
    -trim -bordercolor "$bcolor" -border "$bsize" +repage \
    $outfile'