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

BEVELBORDER


Applies a bevel effect to border of an image.

Download Script

last modified: April 25, 2015



USAGE: bevelborder [-s size] [-m method] [-p percent] [-c contrast] [-b bcolor] [-a amount] [-t type] infile outfile
USAGE: bevelborder [-h or -help]

-s .... size ............ size of border in pixels; same in both dimensions;
......................... default equals 10% of min(imagewidth, imageheight)
-m .... method .......... bevel method; choices are: outer, inner or split;
......................... default=outer
-p .... percent ......... split percent between outer and inner bevel;
......................... 100 is outer bevel only; 0 is inner bevel only;
......................... default=50 applies only to method=split
-c .... contrast ........ contrast percent for bevel; 0<=integer<=100;
......................... default=50
-b .... bcolor .......... border coloring; any IM opaque color is allowed;
......................... default is no coloring
-a .... amount .......... amount of coloring; 0<=integer<=100;
......................... default=25
-t .... type ............ type of compose; hardlight, linearlight or
......................... vividlight; default=hardlight

PURPOSE: To applies a bevel effect to the border of an image.

DESCRIPTION: BEVELBORDER applies a bevel effect to the border of an image. The bevel can be an outer bevel (raised effect), an inner bevel (depressed effect) or a split (mix) of the two. The border may also be colorized.

ARGUMENTS:

-s size ... SIZE is the dimensions of the border region in pixels. The same value is used in both dimensions. Values are integers greater than 0. The default is 10% of the min(width,height) of the image.

-m method ... METHOD is the bevel method. Choices are: outer, which makes a raised effect; inner, which makes a depressed effect; and split, which is part raised and part depressed. The amount of each is controlled by the percent argument. The default is outer.

-p percent ... PERCENT is the percent split between outer and inner bevels. Values are integers such that 0<=percent<=100. A value of 100 is full outer bevel. A value of 0 is full inner bevel. The default is 50 and only applies when the method=split.

-c contrast ... CONTRAST percent for innerbevel or outerbevel. Values are integers between 0 and 100. The default=50.

-b bcolor ... BCOLOR is the bevel colorization color. Any valid opaque IM color is allowed. The default is no additional colorization.

-a amount ... AMOUNT of colorization. Values are integers between 0 and 100. The default=25.

-t type ... TYPE of compose. Choices are: hardlight, linearlight and vividlight. The default=hardlight

REQUIREMENTS: IM 6.5.9.0 or higher due to the use of -brightness-contrast.

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

Arguments:
-s 12 -m outer
(default)

Arguments:
-s 12 -m inner

Arguments:
-s 12 -m split

Arguments:
-s 12 -m split -p 25

Arguments:
-s 12 -m split -p 50

Arguments:
-s 12 -m split -p 75

Arguments:
-s 12 -m outer -c 50 -b red -a 25

Arguments:
-s 12 -m inner -c 50 -b red -a 25

Arguments:
-s 12 -m split -c 50 -b red -a 25

Arguments:
-s 12 -m outer -c 75 -b red -a 25

Arguments:
-s 12 -m inner -c 75 -b red -a 25

Arguments:
-s 12 -m split -c 75 -b red -a 25

Arguments:
-s 12 -m outer -a 25 -t hardlight

Arguments:
-s 12 -m outer -a 25 -t linearlight

Arguments:
-s 12 -m outer -a 25 -t vividlight



What the script does is as follows:

  • Creates a gray image the size of the input with the
    amount of border removed
  • Applies a frame to the gray image to extend it back
    to the size of the original image
  • Applies contrast to the this image
  • Composites the original image with the framed image

This is equivalent to the following IM commands for the case of method=outer.

  • ww=`convert $infile -ping -format "%w" info:`
  • hh=`convert $infile -ping -format "%h" info:`
  • wd=`convert xc: -format "%[fx:$ww-2*$size]" info:`
  • ht=`convert xc: -format "%[fx:$hh-2*$size]" info:`
  • contr1=`convert xc: -format "%[fx:$contrast-100]" info:`
  • wsize2=$size
  • hsize2=0
  • colorize=""
  • convert $infile -size ${wd}x${ht} xc:"gray(50%)" \
    \( -clone 1 -frame ${size}x${size}+${wsize2}+${hsize2} \
    -auto-level -black-threshold 25% -white-threshold 75% $colorize \
    -brightness-contrast 0,${contr1}% \
    -clone 1 -gravity center -composite \) \
    -delete 1 -compose $type -composite \
    $outfile