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.

BUMPTEXT


Applies a raised text effect onto an image.

Download Script

last modified: December 15, 2018



USAGE: bumptext -t text -s size [-p pointsize] [-f font] [-m mode] [-a angles] [-i intensity] [-g gravity] [-o offsets] [-c color] [-b blendval] infile outfile
USAGE: bumptext [-h or -help]

-t .... text ............ text to apply to image; enclose in quotes
-s .... size ............ size of text box; can be specified as WIDTH,
......................... WIDTHx, xHEIGHT or WIDTHxHEIGHT
-p .... pointsize ....... text pointsize; integer>0; default will be
......................... determined from textbox width
-f .... font ............ font name or path to font file; default=Helvetica
-m .... mode ............ text mode; mode is either label or caption;
......................... default=label
-a .... angles .......... lighting directions; azimuthxaltitude; azimuth
......................... angles are integers between 0 and 360 degrees;
......................... altitude angles are integers between 0 and 90
......................... degrees; default="120x45"
-i .... intensity ....... intensity or strength of the bump text; integer>=0;
......................... default=20
-g .... gravity ......... gravity location for placing the text on the image;
......................... default=northwest
-o .... offsets ......... x and y pixel offsets of the text location relative
......................... to the gravity settings; default="+0+0"
-c .... color ........... colorization color for the image;
......................... any valid opaque IM color specification;
......................... default=white
-b .... blendval ........ colorization blending value; 0<=integer<=100;
......................... 0 is no colorization and 100 is full colorization;
......................... default=0

PURPOSE: To apply a raised text effect onto an image.

DESCRIPTION: BUMPTEXT applies a raised text effect onto an image. The text my be applied in either label or caption mode. Optionally, the image may be colorized.

ARGUMENTS:

-t text ... TEXT to apply to image. Be sure to enclose in quotes.

-s size ... SIZE of text box. In label mode, the text will be placed all in one line. The size of the text will be determined either by the text box width or height or pointsize. Specifying pointsize and width or height is not a valid combination. In caption mode, the text will be placed in multiple rows as determined by the text box width and height. Pointsize may optionally be supplied in addition to the text box width and height.

-p pointsize ... POINTSIZE is the size of the font. Values are integers greater than 0. The default is unspecified, so that the pointsize will be determined from the textbox width, height or widthxheight.

-f font ... FONT is the text font or path to the font file. The default is Helvetica.

-m mode ... MODE for adding text. Options are either label or caption. In label mode the text will all be in one row as determined by either the text box width or height or pointsize. In caption mode, the text will be on multiple rows to fill the text box width and height. The pointsize may be optionally specified along with the text box width and height.

-a angles ... Angles are the AZIMUTHxALTITUDE angles used to specify the direction of lighting to create the bump effect. Azimuth angles are integers between 0 and 360 degrees. Altitude angles are integers between 0 and 90 degrees. The default="120x45"

-i intensity ... INTENSITY is the intensity or strength of the raised text. Values are integers>=0. The default=20

-g gravity ... GRAVITY is the standard IM -gravity locations for placing the text. Choices are: northwest, north, northeast, west, center, east, southwest, south and southeast. The default=northwest.

-o offsets ... OFFSETS are the x and y pixel offsets of the text location from the gravity settings. This is implemented via the -geometry setting. The default="+0+0" or no offset from the specified gravity setting.

-c color ... COLOR is the colorization color to apply to the image. Choices are any valid opaque IM color specification. The default=white See http://imagemagick.org/script/color.php

-b blendval ... BLENDVAL is the colorization blending amount. Values are integers between 0 and 100. A value of 0 is no colorization (the image is unchanged). A value of 100 changes the image to a constant color specified by the color argument. The default=0.

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


Original Image

 

Arguments:
-m label -s 300x -b 0 -a 120x45 -i 20 -g southeast -o "+10+10" -t "HAPPY HOLIDAYS"

 

Arguments:
-m label -s 300x -c white -b 70 -a 120x45 -i 20 -g southeast -o "+10+10" -t "HAPPY HOLIDAYS"

 

Arguments:
-m label -s 300x -c white -b 70 -a 120x45 -i 20 -g northwest -o "+10+10" -t "HAPPY HOLIDAYS"

 

Arguments:
-m caption -s 280x -p 36 -c white -b 70 -a 120x45 -i 20 -g northwest -o "+10+10" -t "HAPPY HOLIDAYS"


What the script does is as follows:

  • Uses either label or caption to create white text on a
    black background and determines the width and height of
    the textbox from that image
  • Uses -shade to give a 3D effect to the text and makes the
    background of the text transparent
  • Uses -colorize to adjust the blending color of the image
  • Overlays the text image onto the colorized images at the desired location

This is equivalent to the following IM commands for the label case.

  • convert $infile -alpha off +repage -fill $color -colorize ${blendval}% $tmp1
  • ww=`echo "${size}x" | cut -dx -f1`
  • hh=`echo "${size}x" | cut -dx -f2`
  • convert -background black -fill white \
    -font $font -gravity center \
    -size ${ww}x ${mode}:"$text" -shade "$angles" $tmp2
  • hh=`convert $tmp2 -ping -format "%h" info:`
  • grayval=`convert $tmp2[1x1+0+0] -format "%[fx:100*u.r]" info:`
  • convert $tmp1 \( $tmp2 -trim +repage -transparent "gray($grayval%)" \) \
    -gravity "$gravity" -geometry "$offsets" -compose modulate \
    -set option:compose:args $intensity -composite $outfile