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

EMBROIDERY


Applies an embroidery effect to each color in an image.

Download Script

last modified: May 11, 2016



USAGE: embroidery [-n numcolors ] [-p pattern] [-t thickness] [-g graylimit] [-f fuzzval] [-b bgcolor] [-a angle] [-r range] [-i intensity] [-e extent] [-B bevel] [-A azimuth] [-E elevation] [-C contrast] [-S spread] [-N newseed] [-M mix] infile outfile

USAGE: embroidery [-h or -help]

-n ... numcolors ... number of desired or actual colors in image; integer>0;
.................... default=8
-p ... pattern ..... weave pattern; choices are either linear (1) or crosshatch (2);
.................... default=linear
-t ... thickness ... weave thickness; integer>=1; default=2
-g ... graylimit ... limit colors near black and near white to
.................... gray(graylimit%) and gray(100%-graylimit%);
.................... 0<=integer<=100; default=20
-f ... fuzzval ..... fuzz value for recoloring near black and near white;
.................... 0<=integer<=100; default=20
-b ... bgcolor ..... actual background color in image; default is most the
.................... frequent color
-a ... angle ....... initial pattern angle for background color;
.................... -360<=integer<=360; default=0
-r ... range ....... range of pattern angles; 0<=integer<=360; default=90
-i ... intensity ... shadow intensity; higher is darker; 0 is no shadow;
.................... 0<=integer<=100; default=25
-e ... extent ...... shadow extent; integer>=0; 0 is no shadow; default=2
-B ... bevel ....... pattern bevel amount; integer>=0; default=4
-A ... azimuth ..... bevel azimuth angle; -360<=integer<=360; default=130
-E ... elevation ... bevel elevation angle; 0<=integer<=90; default=30
-C ... contrast .... bevel sigmoidal-contrast amount; integer>=0;
.................... default=0 (no added contrast)
-S ... spread ...... pattern spread (diffusion); integer>=0; default=1
-N ... newseed ..... pattern new seed value; integer>=0;
.................... default is random seed value
-M ... mix ......... mixing between before and after spread result;
.................... 0<=integer<=100; 100 is all spread; 0 is no spread;
.................... default=100

PURPOSE: To apply an embroidery effect to each color in an image.

DESCRIPTION: EMBROIDERY applies an embroidery effect to each color in an image. The image must have limited number of colors or only the top most frequent colors will be used. Each color will get the same pattern, but at different rotation angles.

ARGUMENTS:

-n numcolors ... NUMCOLORS is the number of desired or actual colors in the image. Values are integers>0. The default=8.

-p pattern ... PATTERN is the weave pattern. The choices are either linear (1) or crosshatch (2). The default=1.

-t thickness ... THICKNESS is the weave thickness. Values are integers>=1. The default=2.

-g graylimit ... GRAYLIMIT limits (converts) the colors near black and near white to gray(graylimit%) and gray(100%-graylimit%). Values are 0<=integers<=100. The default=20.

-f fuzzval ... FUZZVAL is the fuzz value used for recoloring near black and near white. Values are 0<=integers<=100. The default=20.

-b bgcolor ... BGCOLOR is the actual background color in the image. The default is most the frequent color.

-a angle ... ANGLE is the initial pattern angle used for the background color. Values are -360<=integers<=360. The default=0 (horizontal)

-r range ... RANGE is the range of pattern angles over all the colors. Values are 0<=integers<=360. The default=90 (deg).

-i intensity ... INTENSITY is the shadow intensity. Higher is darker. 0 is no shadow. Values are 0<=integers<=100. The default=25.

-e extent ... EXTENT is the shadow extent in pixels. Values are integers>=0. 0 is no shadow. The default=2.

-B bevel ... BEVEL is the pattern bevel amount. Values are integers>=0. The default=4.

-A azimuth ... AZIMUTH is the bevel azimuth angle. Values are -360<=integers<=360. The default=130.

-E elevation ... ELEVATION is the bevel elevation angle. Values are 0<=integers<=90. The default=30.

-C contrast ... CONTRAST is the bevel sigmoidal-contrast amount. Values are integers>=0. The default=0 (no added contrast)

-S spread ... SPREAD is the pattern spread (diffusion). Values are integers>=0. The default=1.

-N newseed ... NEWSEED is the pattern (new) seed value. Values are integers>=0. The default is a random seed value.

-M mix ... MIX is the mixing of the before and after spread result. Values are 0<=integers<=100. 100 is all spread. 0 is no spread. The default=100

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 Linear Pattern Thickness

Original
(source)

 

Arguments:
-n 8 -p linear -t 2

 

Arguments:
-n 8 -p linear -t 3



Example 2 -- Variation in Crosshatch Pattern Thickness

Original
(source)

 

Arguments:
-n 8 -p crosshatch -t 2

 

Arguments:
-n 8 -p crosshatch -t 3

 

Arguments:
-n 8 -p crosshatch -t 5



Example 3 -- Variation in Linear Pattern Shadow Intensity

Original
(source)

 

Arguments:
-n 8 -p linear -t 2 -i 0

 

Arguments:
-n 8 -p linear -t 2 -i 25

 

Arguments:
-n 8 -p linear -t 2 -i 50



Example 4 -- Variation in Linear Pattern Contrast (No Shadow)

Original
(source)

 

Arguments:
-n 8 -p linear -t 2 -i 0 -C 0

 

Arguments:
-n 8 -p linear -t 2 -i 0 -C 10



Example 5 -- Variation in Linear Pattern Graylimit

Original
(source)

 

Arguments:
-n 8 -p linear -t 2 -g 20 -f 20

 

Arguments:
-n 8 -p linear -t 2 -g 0 -f 0
(no gray limiting)



What the script does is as follows:

  • Gets the top numcolors that are most frequently used in the image
  • Creates a colormap image and applies -remap to ensure only those
    colors are in the image
  • Limits black and white to gray(20%) and gray(80%)
  • Creates one of two tiled out pattern images
  • Isolates each color in the image as a new image, rotates the pattern
    by different amounts and applies a softlight composite
  • Flattens all the processed color images into the output image

See the script for details