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

STRIATIONS


Applies radial or circular striations to image.

Download Script

last modified: September 26, 2017



USAGE: striations [-r radius ] [-c center] infile outfile
USAGE: striations [-h or -help]

-t .... type ............. type of striations; choices are radial (or r)
.......................... or circular (c); default=radial
-r .... radius ........... radius from center point where striations begin;
.......................... integer>=0; default is half the minimum image dimension
-c .... center ........... center point for striation effect; center=cx,cy;
.......................... integer>=0; default is center of image
-k .... column ........... column to use for circular striations; integers;
.......................... 0<=column<width

PURPOSE: To apply radial or circular striations to image.

DESCRIPTION: STRIATIONS applies radial striations to image starting at a user specified center point and radius.

ARGUMENTS:

-t type ... TYPE of striations. Choices are radial (or r) or circular (or c). The default is radial.

-r radius ... RADIUS is the radial distance from the center point at which the striations begin. Values are integers>=0. The default is half the minimum dimension of the image.

-c center ... CENTER=cx,cy are the comma separated coordinates in the image from where the radial striations eminate. Values are integers>=0. The default is the center of the image.

-k column ... COLUMN of the polar image to use for generating the circular striations. Values are integers, such that 0<=column<width of the image. The default=0.

NOTE: Requires IM 6.4.2-8 or higher due to the use of -distort polar/depolar.

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

NOTE: The radial formula has been corrected. But I have not modified the examples. So the radius of the effect may be slightly different if one repeats the examples.

Radial Striations

Original

Arguments:
-t r -r 50

Arguments:
-t r -r 100

Arguments:
-t r -r 150

Arguments:
-t r -r 200



Circular Striations

Original

Arguments:
-t c -r 50

Arguments:
-t c -r 100

Arguments:
-t c -r 100 -k 130

Arguments:
-t r -r 150



What the script does is as follows:

  • Converts image to polar coordinates
  • Crops the height as determined by the radius
  • Repeats the last cropped row to fill the height back to original size
  • Converts back to rectangular coordinates

This is equivalent to the following IM commands

  • ww=`convert $infile -format "%[fx:w]" info:`
  • hh=`convert $infile -format "%[fx:h]" info:`
  • rad1=`convert $infile -format "%[fx:floor(2*$rad*h/sqrt(w*w+h*h))]" info:`
  • hmr=`convert xc: -format "%[fx:max(1,$hh-$rad1)]" info:`
  • convert $infile -distort depolar -1,0,$cx,$cy $infile
  • convert $tmpA1[${ww}x${rad1}+0+0] \
    \( $tmpA1[${ww}x1+0+${rad1}] -scale ${ww}x${hmr}! \) \
    -append -crop ${ww}x${hh}+0+0 +repage \
    -distort polar -1,0,$cx,$cy $outfile