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.

ZOOMBLUR


Applies a radial or zoom blur to an image.

Download Script

last modified: December 16, 2018



USAGE: zoomblur [-z zoom] [-e] infile outfile
USAGE: zoomblur [-h or -help]

-a .... amount ..... amount of zoom blur; float; amount>=1; default=1.2
-e ................. expands the output image by the amount of zoom

PURPOSE: To apply a radial or zoom blur to an image.

DESCRIPTION: ZOOMBLUR applies a radial blur to an image by a process of iterative zooming and blending.

ARGUMENTS:

-a amount ... AMOUNT is the zoom factor. Values are floats greater than or equal to 1. A value of 1 produces no effect. Larger values increase the radial blur. Typical values are between 1 and 1.5. The default is 1.2. Note that the large the amount, the more iterations it will take.

-e ... Expands the output image size by the amount of the zoom.

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


Zoom Blur
http://www.jhlabs.com/ip/blurring.html

Original

Arguments:
-a 1.1

Arguments:
-a 1.2

Arguments:
-a 1.3

Arguments:
-a 1.4



Zoom Blur With vs Without Expand
http://www.jhlabs.com/ip/blurring.html

Original

Arguments:
-a 1.2

Arguments:
-a 1.2 -e



What the script does is as follows:

  • Successively zooms the image by an increasing zoom factor
  • Blends the result with image
  • Repeats for each iteration until the full zoom value is reached

This is equivalent to the following IM commands

  • rad=`convert $infile -format "%[fx:hypot(w/2,h/2)]" info:`
  • zoomfrac=`convert xc: -format "%[fx:($amount-1)]" info:`
  • iter=`convert xc: -format "%[fx:int($zoomfrac*$rad)]" info:`
  • ww=`convert $infile -format "%w" info:`
  • hh=`convert $infile -format "%h" info:`
  • if [ "$expand" = "yes" ]; then
  • ww=`convert $infile -format "%[fx:floor(w*$amount)]" info:`
  • hh=`convert $infile -format "%[fx:floor(h*$amount)]" info:`
  • fi
  • i=1
  • convert $infile $tmpA
  • while [ $i -le $iter ]; do
  • j=`expr $i + 1`
  • new=`convert xc: -format "%[fx:100/$j]" info:`
  • old=`convert xc: -format "%[fx:100-$new]" info:`
  • s=`convert xc: -format "%[fx:1 + $zoomfrac*$i/$iter]" info:`
  • convert $tmpA -resize $s% -gravity center -crop ${ww}x${hh}+0+0 +repage $tmpC
  • composite -blend $old%x$new% -gravity center $tmpA $tmpC $tmpA
  • i=`expr $i + 1`
  • done
  • convert $tmpA $outfile