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.

EMBOSS


Applies an emboss effect to an image.

Download Script

last modified: December 15, 2018



USAGE: emboss [-m method] [-a azimuth] [-e elevation] [-d depth] [-i intensity] [-c compose] infile outfile
USAGE: emboss [-h or -help]

-m .... method .......... method of embossing; choices are 1 or 2;
......................... 1 simulates the GIMP approach;
......................... 2 simulates the Photoshop approach; default=1
-a .... azimuth ......... azimuth angle for light source; 0<=integer<=360;
......................... counterclockwise from positive x axis (East);
......................... default=135 (NorthWest)
-e .... elevation ....... elevation angle for light source; 0<=integer<=90;
......................... upwards from x-y plane; default=45; only for method=1
-d .... depth ........... depth of emboss effect; integer>0; default=1
-i .... intensity ....... intensity of emboss effect; -50<=integer<=50;
......................... default=0; only for method=2
-c .... compose ......... compose method to use to composite emboss result
......................... with input image. The default is no composite.
-g .... gray ............ desired base graylevel for method=1; 0<float<1;
......................... default is no adjustment from normal shading

PURPOSE: To apply an emboss effect to an image.

DESCRIPTION: EMBOSS applies an emboss effect to an image. Two methods are available. The first simulates the GIMP approach. The second simulates the Photoshop approach.

ARGUMENTS:

-m method ... METHOD of embossing. The choices are 1 or 2. Method 1 simulates the GIMP approach and uses parameters of azimuth, elevation and depth. The second simulates the Photoshop approach and uses parameters of azimuth, depth and intensity. The default=1.

-a azimuth ... AZIMUTH is the angle in degrees in the x-y plane measured counterclockwise from EAST to the light source. Values are integers in the range 0<=azimuth<=360. The default=135 (NorthWest).

-e elevation ... ELEVATION is the angle in degrees upwards from the x-y plane to the light source. Values are integers in the range 0<=elevation<=90. The default=45. Note this parameter is only used with method=1

-d depth ... DEPTH controls the depth effect in the embossing. For method=1, it adjust the contrast of the emboss effect. For method=2, it adjust the separation in pixels of the dark and light parts. Values are integers>0. The default=1

-i intensity ... INTENSITY controls the contrast of the emboss effect in method=2. Values are integers in the range of -50<=intensity<=50. Positive values increase the contrast and negative values decrease the contrast. The default=0

-c compose ... COMPOSE method to use to composite emboss result with input image. Valid compose methods include: bumpmap, multiply, color_burn, color_dodge, linear_burn, linear_dodge, linear_light, hard_light, soft_light, pegtop_light, pin_light, vivid_light, overlay. The default is no composite.

-g gray ... GRAY is the desired base graylevel for method=1. Values are 0<float<1. The default is no adjustment from the normal shading base level which gets brighter as the elevation angle increases according to the sin(elevation). Nominal value for elevation=45 is gray=.707

REQUIREMENTS: IM 6.5.3-4 in order to support -set option:compose:args in method 2 and IM 6.4.8-8 in order to support -function polynomial in method 1.

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


Method 1 -- Variation In Depth

Original

Arguments:
-m 1 -d 1

Arguments:
-m 1 -d 2

Arguments:
-m 1 -d 5



Image 1 -- Method 1 -- Variation In Elevation

Original

Arguments:
-m 1 -d 2 -e 33

Arguments:
-m 1 -d 2 -e 45

Arguments:
-m 1 -d 2 -e 67

Arguments:
-m 1 -d 2 -e 33 -g 0.7

Arguments:
-m 1 -d 2 -e 45 -g 0.7

Arguments:
-m 1 -d 2 -e 67 -g 0.7



Image 1 -- Method 2 -- Variation In Depth

Original

>

Arguments:
-m 2 -d 1

Arguments:
-m 2 -d 2

Arguments:
-m 2 -d 5



Image 1 -- Method 2 -- Variation In Intensity

Original

Arguments:
-m 2 -d 2 -i 0

Arguments:
-m 2 -d 2 -i 20

Arguments:
-m 2 -d 2 -i 40



Image 2 -- Method 1 -- Variation In Elevation

Original
(http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx)

Arguments:
-m 1 -d 5 -e 33

Arguments:
-m 1 -d 5 -e 45

Arguments:
-m 1 -d 5 -e 67



Image 2 -- Method 2 -- Variation In Depth

Original

Arguments:
-m 2 -d 1

Arguments:
-m 2 -d 3

Arguments:
-m 2 -d 6



Image 3 -- Method 1 -- Variation In Compose

Original

Arguments:
-m 1 -d 10 -c multiply
or
-m 1 -d 10 -c bumpmap

Arguments:
-m 1 -d 10 -c linear_burn

Arguments:
-m 1 -d 10 -c color_burn

Arguments:
-m 1 -d 10 -c pegtop_light

Arguments:
-m 1 -d 10 -c soft_light

Arguments:
-m 1 -d 10 -c overlay

Arguments:
-m 1 -d 10 -c color_dodge

Arguments:
-m 1 -d 10 -c linear_dodge

Arguments:
-m 1 -d 10 -c vivid_light

Arguments:
-m 1 -d 10 -c linear_light

Arguments:
-m 1 -d 10 -c hard_light

Arguments:
-m 1 -d 10 -c pin_light



What the script does is as follows for method=1:

  • Applies -shade to the grayscale version of the image
  • Computes the mean of the above result
  • Computes graylevel linear stretch parameters for contrast change
    relative to the mean using the depth parameter
  • Applies the linear stretch of the graylevels using -function polynomial

This is equivalent to the following IM commands

  • convert $infile -colorspace gray -shade ${azimuth}x${elevation} $tmpA1
  • mean=`convert $tmpA1 -format "%[fx:mean]" info:`
  • aa=$depth
  • bb=`convert xc: -format "%[fx:$mean*(1-$depth)]" info:`
  • convert $tmpA1 -function polynomial "$aa,$bb" $outfile