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.

MOSAICTILES


Applies mosaic tiles effect to image.

Download Script

last modified: December 15, 2018



USAGE: mosaictiles [-t tsize] [-w width ] [-b bright] [-A] [-r ripples]
[-g granular] [-n newseed] infile outfile

USAGE: mosaictiles [-h or -help]

-t ... tsize ...... size of tiles; integer>0; default=30
-w ... width ...... width of grout; integer>0; default=3
-b ... bright ..... brightness of grout; 0<=integer<=100; default=0
-c ... color ...... grout color; any valid opaque IM color is allowed
-A ................ antialias grout edges
-r ... ripples .... extent of ripples of grout; integer>=0; default=15
-g ... granular ... granularity of noise image used to make rippled
................... grout; integer>=0; default=5
-n ... newseed .... seed value of noise image; integer>=0; default is
................... random seed

PURPOSE: To apply a mosaic tiles effect to image.

DESCRIPTION: MOSAICTILES applies a mosaic tiles effect to image. The user may control the tile size, grout thickness, grout brightness and grout ripples. This script is similar to the Photoshop Mosiac Tiles filter.

ARGUMENTS:

-t tsize ... TSIZE is the size of the tiles in the x and y direction. Values are integers greater than 0. The default=30.

-w width ... WIDTh of the grout. Values are integers greater than 0. The default=3.

-b bright ... BRIGHT is the brightness of the grout. Values are between 0 and 100. The default=0.

-c color ... COLOR is the grout color. Any valid opaque IM color is allowed.

-A ... ANTIALIAS grout.

-r ripples ... RIPPLES are the extent of the ripples (wiggles) in the grout. Values are integers greater than or equal to 0. The default=15.

-g granular ... GRANULAR is the granularity of the noise image used to make the rippled grout. Smaller values gives small curls, while larger values are broader curves. Values are integers greater than or equal to 0. The default=5.

-n newseed ... NEWSEED is the seed value for the random noise image. Values are integers greater than or equal to 0. The default is random seed values.

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 Tile Size

Original

Arguments:
-t 15 -w 3 -b 0 -n 100

Arguments:
-t 30 -w 3 -b 0 -n 100

Arguments:
-w 45 -b 5 -s 1



Example 2 -- Variation in Grout Width

Original

Arguments:
-t 15 -w 3 -b 0 -n 100

Arguments:
-t 15 -w 5 -b 0 -n 100

Arguments:
-t 15 -w 10 -b 0 -n 100



Example 3 -- Variation in Grout Brightness

Original

Arguments:
-t 15 -w 3 -b 0 -n 100

Arguments:
-t 15 -w 3 -b 50 -n 100

Arguments:
-t 15 -w 3 -b 75 -n 100



Example 4 -- Variation in Grout Ripples

Original

Arguments:
-t 15 -w 3 -b 0 -r 5 -n 100

Arguments:
-t 15 -w 3 -b 0 -r 15 -n 100

Arguments:
-t 15 -w 3 -b 0 -r 25 -n 100



Example 4 -- Variation in Granularity

Original

Arguments:
-t 15 -w 3 -b 0 -g 3 -n 100

Arguments:
-t 15 -w 3 -b 0 -g 5 -n 100

Arguments:
-t 15 -w 3 -b 0 -g 10 -n 100



Example 5 -- Variation in Seed

Original

Arguments:
-t 15 -w 3 -b 0 -n 100

Arguments:
-t 15 -w 3 -b 0 -n 200

Arguments:
-t 15 -w 3 -b 0 -n 300



Example 6 -- Variation in Antialiasing

Original

Arguments:
-t 15 -w 3 -b 0 -n 100

Arguments:
-t 15 -w 3 -b 0 -n 100 -A



Example 7 -- Different Grout Color

Original

Arguments:
-t 15 -w 3 -c purple -b 0 -n 100

Arguments:
-t 15 -w 3 -c purple -b 50 -n 100



What the script does is as follows:

  • Creates a straight line grid pattern with the desired spacing and line width
  • Uses a blurred random noise image with a displacement operation to apply wiggles to the grid
  • Uses compose multiply to composite the grid over the image

This is equivalent to the following IM commands

  • ww=`convert $infile -format "%w" info:`
  • hh=`convert $infile -format "%h" info:`
  • ww2=$((ww+tsize))
  • hh2=$((hh+tsize))
  • tsize=$((tsize+width))
  • convert \( -size ${tsize}x${tsize} xc:black \
    -size ${width}x${tsize} xc:white +append \
    -size ${tsize}x${width} xc:white -append \) \
    -write mpr:tile +delete -size ${ww2}x${hh2} tile:mpr:tile $tmpA2
  • convert -size ${ww2}x${hh2} xc: -seed $newseed +noise random \
    -set colorspace RGB -colorspace gray \
    -blur 0x${granular} -contrast-stretch 0 $tmpA3
  • convert $tmpA2 $tmpA3 $setcspace -virtual-pixel black \
    -define compose:args=${ripple}x${ripple} -compose displace -composite \
    -gravity center -crop ${ww}x${hh}+0+0 +repage -threshold 1% $tmpA2
  • convert $infile \
    \( -clone 0 -fill $color -colorize 100 \) \
    \( $tmpA2 -fill black -colorize $bright \) \
    -compose multiply -composite $outfile