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

VIGNETTE


Applies a vignette effect to a picture.

Download Script

last modified: September 26, 2017



# USAGE: vignette [-i inner] [-o outer] [-f feather] [-c color] [-a amount] infile outfile # USAGE: vignette [-help|-h]

-i ... inner ..... inner radius of vignette where not darkened;
.................. integer percent of image dimension; default=0
-o ... outer ..... outer radius of vignette where darkest;
.................. integer percent of image dimension; default=150
-f ... feather ... feathering amount for inner radius; float>=0;
.................. default=0
-t ... tint ...... vignette color; any IM opaque color; default=black
-a ... amount .... vignette amount; 0<=integer<=0; default=100

# PURPOSE: Applies a vignette effect to a picture.

# DESCRIPTION: VIGNETTE applies a vignette effect to a picture. The # inner and outer radii of the vignette can be controlled as well as # the vignette color and amount. For non-square images the vignette # effect will be elliptical to reach the corners.

ARGUMENTS:

-i inner ... INNER vignette radius as percent of image dimension. The default=0 means the vignette starts near the image center.

-o outer ... OUTER vignette radius as percent of image dimension. The default=150, which is about the image corners.

-f feather ... FEATHER is the amount of feathering or smoothing of the transition around the inner radius. Values are floats>0. The default=0

-c color ... COLOR is the vignette color. Any valid opaque IM color is allowed. The default=black.

-a amount ... AMOUNT is the overal coloring amount. Values are integers in the range 0 to 100. A value of zero means no vignette. The default=100 means full vignette color.

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
(http://photoshoptutorials.ws/photoshop-tutorials/photo-effects/lomography.html)

Arguments:
-i 50 -o 150 -c black -a 100

Arguments:
-i 50 -o 125 -c black -a 100

Arguments:
-i 50 -o 100 -c black -a 100

Arguments:
-i 50 -o 100 -c black -a 50

Arguments:
-i 50 -o 150 -c red -a 100

Arguments:
-i 50 -o 125 -c red -a 100

Arguments:
-i 50 -o 100 -c red -a 100

Arguments:
-i 50 -o 100 -c red -a 50



Example 2

Original
(http://photoshopgirl.com/01/29/holga-medium-format-effect)

Arguments:
-i 10 -o 150 -f 0 -c black -a 100

Arguments:
-i 50 -o 125 -f 0 -c black -a 100

Arguments:
-i 50 -o 125 -f 20 -c black -a 100

Arguments:
-i 50 -o 150 -f 0 -c pink -a 50

Arguments:
-i 50 -o 150 -f 0 -c pink -a 100



Example 3

Original
(http://www.webdesign.org/web/photoshop/photoshop-basics/photo-correction-101-auto-color.8149.html)

Arguments:
-i 50 -o 150 -f 0 -c black -a 100

Arguments:
-i 50 -o 150 -f 20 -c black -a 100



What the script does is as follows for mode=intensity:

  • Creates a radial gradient, resizes it and crops it.
  • Puts the modified radial gradient into the alpha channel of the image
  • Flattens the result over a background color

This is equivalent to the following IM commands:

  • convert -quiet -regard-warnings "$infile" +repage "$tmpA1"
  • ww=`convert $tmpA1 -format "%w" info:`
  • hh=`convert $tmpA1 -format "%h" info:`
  • wwo=`convert xc: -format "%[fx:$outer*$ww/100]" info:`
  • hho=`convert xc: -format "%[fx:$outer*$hh/100]" info:`
  • mwh=`convert xc: -format "%[fx:$outer*min($ww,$hh)/100]" info:`
  • if [ "$inner" = "0" ]; then
    mlevel=""
    else
    inner=$((100-inner))
    mlevel="-level 0x$inner%"
    fi
  • if [ "$feather" = "0" ]; then
    feathering=""
    else
    feathering="-blur ${feather}x65000"
    fi
  • convert -background $color $tmpA1 \
    \( -size ${mwh}x${mwh} radial-gradient: -resize ${wwo}x${hho}! \
    -gravity center -crop ${ww}x${hh}+0+0 +repage $mlevel $plevel $feathering \) \
    -alpha off -compose copy_opacity -composite \
    -compose over -flatten $outfile