Fred's ImageMagick Scripts



 

 

MELT


Creates a melting-like blur effect in an image.

Download Script

last modified: July 15, 2008



USAGE: melt [-l length] [-d direction] [-b blur] infile outfile
USAGE: melt [-h or -help]

-l .... length ....... length of melt effect; integer>0
-d .... direction .... direction of melt; North,South,East,West
...................... default=South
-b .... blur ......... initial blur amount; float>=0; default=0

PURPOSE: To create a melting-like blur effect in an image.

DESCRIPTION: MELT creates a melting-like blur effect in an image using an iterative offset and compare technique. The brighter of the comparison values will be used.

ARGUMENTS:

-l length ... LENGTH is the melt distance. Values are integers greater than 0. The default is 10. The length determines the number of iterations.

-d direction ... DIRECTION is the melt direction. Values may be North, South, East, West (or abbreviations N,S,E,W). The default=South

-b blur ... BLUR is an initial blurring of the image to make the pixels wider before applying the melting process. Values for blur are floats>=0. Typical values are a few pixels. 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


Image Melt
http://www.cescg.org/CESCG97/boros/

Original

Arguments:
-l 10 -d South

Arguments:
-l 10 -d East



What the script does is as follows:

  • Shifts the image by one pixel in the desired direction
  • Compares the original with the shifted image
  • Selects the brighter value from the two images
  • Iterates the desired number of times determined by the specified length

This is equivalent to the following IM commands for melt in the South direction.

  • ww=`convert $infile -format "%w" info:`
  • hh=`convert $infile -format "%h" info:`
  • ww1=`expr $ww - 1`
  • hh1=`expr $hh - 1`
  • sub1="${ww}x1+0+0"
  • sub2="${ww}x${hh1}+0+0"
  • convert $infile $tmpA
  • convert $tmpA[$sub1] $tmpA[$sub2] -append $tmpC
  • i=0
  • while [ $i -lt $iter ]
  • do
  • convert $tmpA $tmpC -compose lighten -composite $tmpA
  • convert $tmpA[$sub1] $tmpA[$sub2] -append $tmpC
  • i=`expr $i + 1`
  • done
  • convert $tmpA $outfile