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.

TEXTETCH


Adds text to an image to simulate etching on glass.

Download Script

last modified: August 15, 2019



USAGE: textetch -t text [-p pointsize] [-f font] [-c color] [-g gravity] [-o offset] [-a arc] [-r rotation] [-n noise] [-i imageoffset] [-s scale] [-b brighness] [-C compose] infile [clipart] outfile

USAGE: textetch [-help or -h]

-t ... text .......... text to apply to the input image. Required.
-p ... pointsize ..... pointsize for the text; integer>0; default=28
-f ... font .......... font name or path to font file; default=arial
-c ... color ......... color of font; any valid opaque IM color is allowed;
...................... default="gray(128)"
-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"
-a ... arc ........... arc curvature of the text in degrees; 0<=integer<=360;
...................... default=0
-r ... rotation ...... rotation angle of text; 0<=integer<=360; default=0
-n ... noise ......... noise amount to use to texturize the text; float>=0; default=0.5
-i ... imageoffset ... offset of clipart placement relative to gravity setting; format
...................... is +-X+-Y; default="+0+0"
-s ... scale ......... scale in percent for clipart; integer>0; default=100 (no change)
-b ... brightness .... brightness for clipart; integer>0; default=100 (no change)
-C ... compose ....... compose method for compositing text and clipart; choices are:
...................... over or multiply; default=over

PURPOSE: Adds text to an image to simulate etching on glass.

DESCRIPTION: TEXTETCH adds text to an image to simulate etching on glass. Text is nominally added in one line. Multiple line format is controlled by adding new line \n characters within the text. One optional clipart file may be added. It should have a transparent background and will be converted to grayscale and optionally colorized the same as the text.

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.

-c color ... COLOR of the font. Any valid opaque IM color is allowed. The default="gray(128)".

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

-a arc ... ARC downward curvature of the text in degrees. Values are 0<=integer<=360. The default=0.

-r rotation ... ROTATION angle of text. Values are 0<=integer<=360. The default=0.

-n noise ... NOISE amount to use to texturize the text. Values are float>=0. The default=0.5.

-i imageoffset ... IMAGE OFFSET of clipart placement relative to gravity setting. The format is +-X+-Y; default="+0+0".

-s scale ... SCALE in percent for clipart. Values are integer>0. The default=100 (indicates no change).

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

-C compose ... COMPOSE method for compositing text and clipart; choices are: over (o) or multiply (m). The default=over.

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

Original
(source)

Arguments:
-t "Your Name Here" -f candice -p 48 -c white -a 20 -o +0-200

Arguments:
-t "Your\nName\nHere" -f candice -p 72 -c white -a 20 -o +0-200



Example 2

Original
(source)

Image
Clipart

Arguments:
-t "Your Name Here" -f candice -p 28 -c "gray(128)" -a 20 -o +0-50

Arguments:
-t "Your Name Here" -f candice -p 28 -c white -a 20 -o +0-75 -s 35 -b 200 -i +0-10



Example 3

Original
(source)

Image
Clipart

Arguments:
-t "Your Name Here" -f candice -p 28 -c "rgb(0,128,255)" -a 20 -o +0-50

Arguments:
-t "Your Name Here" -f candice -p 28 -c "rgb(0,128,255)" -a 20 -o +0-75 -s 35 -b 200 -i +0-10



Example 4

Original
(source)

Arguments:
-t "Your\nName\nHere" -f candice -p 72 -c "gray(128)" -a 5 -o +0-75

Arguments:
-t "Your\\Name\\Here" -f candice -p 72 -c "rgb(245,222,179)" -a 5 -o +0-75 -C multiply



What the script does is as follows:

  • Reads the input image
  • Creates a text image on a transparent background using label:
  • Adds Gaussian noise to the text image and converts to grayscale
  • Optionally colorizes it
  • Makes the text half transparent
  • Applies arc distortion
  • Optionally rotates it
  • Composes the processed text image over the input image
  • Writes the output image

This is equivalent to the following IM commands

  • convert "$infile" \
    \( -background none -font $font -pointsize $pointsize -gravity center \
    -fill "white" label:"$text" -channel rgb -shade 270x45 \
    -attenuate $noise +noise gaussian -colorspace gray \
    -fill "$color" -colorize 50 +channel -channel a -evaluate multiply 0.5 +channel \
    -rotate 180 -virtual-pixel none -distort arc "$arcval 180" -rotate $rotation \) \
    -gravity $gravity -geometry "$offset" -compose over -composite \
    "$outfile"