Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial (non-profit) 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

    Please read the Pointers For Use on my home page to properly install and customize my scripts.

TEXTGLOW


Adds glowing text to an image or some background color.

Download Script

last modified: May 30, 2022



USAGE: textglow [-t text] [-p pointsize] [-f font] [-a antialias] [-s spread]
[-I intensify] [-P padding] [-T textcolor] [-G glowcolor] [-B bgcolor] [-g gravity]
[-o offset] [-b brighness] [infile] [bgfile] outfile
USAGE: textglow [-help or -h]

-t ... text ......... text string to apply to the input image; defaults to infile
-p ... pointsize .... pointsize for the text; integer>0; default=64
-f ... font ......... font name or path to font file; default=arial
-a ... antialias .... amount of anti-aliasing (blur sigma); float>=0; default=0
-s ... spread ....... spread of glow (blur sigma value); integer>=0; default=32
-I ... intensify .... glow intensification; float; 1 is no change, float>1 is
..................... amplify, float<1 is attenuate; default=2
-P ... padding ...... padding around text; default=32
-T ... textcolor .... text color; any valid opaque IM color is allowed;
..................... default="magenta"
-G ... glowcolor .... glow color; any valid opaque IM color is allowed;
..................... default="magenta"
-B ... bgcolor ...... background color; any valid IM color is allowed;
..................... can be transparent; default="black"
-g ... gravity ...... gravity setting for offset placement of text; choices are:
..................... center or northwest; default=center
-o ... offset ....... offset of text placement relative to gravity setting; format
..................... is +-X+-Y; default="+0+0"
-b ... brightness ... brightness for clipart; integer>=0; default=100 (no change)

infile is optional and can be a textfile or clipart in place of supplied text string
if textfile, it is an optional white on black "mandatory opaque" binary image of text
if clipart, it is an optional clipart image with "mandatory transparent" background
Only one of textfile or clipart can be used as infile.
bgfile is an optional opaque background file onto which to place the glowing text or art

PURPOSE: Adds glowing text to an image or some background color.

DESCRIPTION: TEXTGLOW adds glowing text or glowing clipart to a background image or some background color. The text can be specified as a string along with a text color, a glow color and a background color. A fully opaque binary text image may be used as an alternate to the text string. Or a transparent clipart image may be used and have a glow around it. The background may simply be some defined color or a background image. If a background image, the background color should be set to transparent. If infile is provided, then it will be tested. If opaque, then it is assumed to be the textfile. If infile has any transparency, then it is assumed to be an artfile.

ARGUMENTS:

-t text ... TEXT string to apply to the image. Required. Must be enclosed in quotes.

-p pointsize ... POINTSIZE for the text. Values are integer>0. The default=28.

-f font ... FONT name or path to font file. The default=arial.

-a antialias ... ANTI-ALIASING amount (blur sigma). Values are float>=0. The default=0.

-s spread ... SPREAD of glow (blur sigma value). The default=32.

-I intensify ... glow INTENSIFICATION. Values are floats. Float=1 is no change, float>1 is amplify, float<1 is attenuate. The default=2.

-P padding ... PADDING around text. The default=32.

-T textcolor ... TEXT COLOR. Any valid opaque IM color is allowed. The default="white".

-G glowcolor ... GLOW COLOR. Any valid opaque IM color is allowed. The default="white".

-B bgcolor ... BACKGROUND COLOR. Any valid IM color is allowed including transparent. The default="black".

-g gravity ... GRAVITY setting for the offset placement of text. The choices are: center (c) or northwest (n). The default=center.

-o offset ... OFFSET placement of the text relative to the gravity setting. The format is +-X+-Y. The default="+0+0"

-b brightness ... BRIGHTNESS adjustment for the clipart. Values are integer>=0. The default=100 (indicates no change)

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 1 --- Text String

Arguments:
-t "THIS IS SOME TEXT" -f "Ubuntu-Bold"



Example 2 --- Text Image

Image

Arguments:



Example 3 --- Clipart

Original
(source)

Arguments:
-I 1



What the script does is as follows:

  • Creates or reads a text image or clipart image
  • Colorizes the image or alpha channel
  • Adds a colored shadow all around the outside
  • Composites the result over a background image or background color
  • Writes the output image

This is equivalent to the following IM commands

  • convert -background black -font $font -pointsize $pointsize \
    -gravity center -fill "white" label:"$text" -alpha off \
    -trim +repage $dir/tmpI.mpc
  • convert "$dir/tmpI.mpc" \
    \( +clone -fill "$textcolor" -colorize 100 \) \
    +swap -compose copy_opacity -composite -compose over \
    \( +clone -background "$glowcolor" -shadow 100x${spread}+0+0 \
    $intensification \) +swap \
    -background "$bgcolor" -layers merge +repage \
    -gravity center -crop "${dims}+0+0" +repage \
    $dir/tmpG.mpc
  • if [ "$bgfile" != "" ]; then
    convert \
    \( $dir/tmpB.mpc -channel rgb -modulate $brightness,100,100 +channel \) \
    $dir/tmpG.mpc -gravity $gravity -geometry $offset \
    -compose over -composite \
    "$outfile"
    else
    convert $dir/tmpG.mpc "$outfile"
    fi