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

MANDALASCOPE


Converts an image into a mandala-like kaleidoscope image.

Download Script

last modified: December 07, 2017



USAGE: mandalascope [-n number] [-s scale] [-r rotation] [ -t translation] [-z zoom] [-b bgcolor] infile outfile
USAGE: mandalascope [-h or -help]

-n ... number ........ number of repetitions; integer>=3; default=12
-s ... scale ......... scale factor; float>0; default=1
-r ... rotation ...... rotation angle in degrees; 0<=integer<=360; default=0
-t ... translation ... translation; 0<=integer<=200; default=0
-z ... zoom .......... zoom factor; float>0; default=1.4
-b ... bgcolor ....... background color; any valid IM color is allowed; default=black

PURPOSE: To convert an image into a mandala-like kaleidoscope image.

DESCRIPTION: MANDALASCOPE converts an image into a mandala-like kaleidoscope image.

ARGUMENTS:

-n number ... NUMBER of repetitions. Values are integers>=3. The default=12.

-s scale ... SCALE factor. Values are floats>0. The default=1.

-r rotation ... ROTATION angle in degrees. Values are 0<=integer<=360. The default=0.

-t translation ... TRANSLATION. Values are 0<=integer<=200. The default=0.

-z zoom ... ZOOM factor. Values are floats>0. The default=1.4.

-b bgcolor ... BGCOLOR is the background color. Any valid IM color is allowed. The default=black.

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 --- Variation in Number

Original

Arguments:
-n 12

Arguments:
-n 8

Arguments:
-n 6

Arguments:
-n 4



Example 2 --- Variation in Zoom

Original

Arguments:
-z 1

Arguments:
-z 1.4

Arguments:
-z 2



Example 3 --- Variation in Scale with Translate=0

Original

Arguments:
-s 1 -t 0

Arguments:
-s 1.5 -t 0

Arguments:
-s 2 -t 0

Arguments:
-s 2.5 -t 0



Example 4 --- Variation in Scale with Translate=50

Original

Arguments:
-s 1 -t 50

Arguments:
-s 1.5 -t 50

Arguments:
-s 2 -t 50

Arguments:
-s 2.5 -t 50



Example 5 --- Variation in Rotation with Translate=0

Original

Arguments:
-r 0 -t 0

Arguments:
-r 30 -t 0

Arguments:
-r 45 -t 0

Arguments:
-r 60 -t 0



Example 6 --- Variation in Rotation with Translate=50

Original

Arguments:
-r 0 -t 50

Arguments:
-r 30 -t 50

Arguments:
-r 45 -t 50

Arguments:
-r 60 -t 50



Example 7

Original

Arguments:
defaults



Example 8

Original

Arguments:
defaults



Example 9

Original

Arguments:
defaults



Example 10

Original

Arguments:
defaults



What the script does is as follows:

  • Uses -distort affine and -distort SRT to crop a section of the image then
    translates, rotates and scales it into repeated patterns in a circular arrangement

This is equivalent to the following IM commands

  • convert \
    "$infile" \
    -virtual-pixel mirror \
    -set option:distort:viewport "%[fx:ceil(h*tan(pi/$number))]x%[h]" \
    -distort affine "%[fx:w/2],0 0,0" \
    -distort SRT "0,0 "%[fx:1/$scale]" $rotate %[fx:$translate*w/100],0" \
    -virtual-pixel none \
    -distort affine "0,%[fx:h-1] %[fx:w-1],%[fx:h-1] 0,0 0,0 %[fx:w-1],0 %[fx:w-1],0" \
    -virtual-pixel mirror \
    -set option:distort:viewport %[fx:w*2]x%[h] \
    -distort SRT 0 \
    -duplicate $((number-1)) \
    -virtual-pixel none \
    -set option:distort:viewport %[h]x%[h] \
    -distort SRT "%[fx:w/2],%[h] "%[fx:1/$zoom]" %[fx:t*360/n] %[fx:h/2],%[fx:h/2]" \
    -background "$bgcolor" \
    -layers merge \
    +repage \
    "$outfile"