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.

EMBROIDERY


Applies an embroidery effect to each color in an image.

Download Script

last modified: January 04, 2024



USAGE: embroidery [-n numcolors ] [-p pattern] [-t thickness] [-g graylimit] [-f fuzzval] [-b bgcolor] [-P process] [-a angle] [-r range] [-i intensity] [-e extent] [-B bevel] [-A azimuth] [-E elevation] [-C contrast] [-S spread] [-N newseed] [-M mix] [-G gain] 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=5
-b ... bgcolor ..... actual background color in image; default is most the
.................... frequent color
-P ... process ..... embroidering processing of background color; choices are:
.................... yes, no, transparent or preserve; default=yes
-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; float>=0;
.................... default=0 for IM >= 6.7.9.5; otherwise default=1
.................... (both cases 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
-G ... gain ........ gain in pattern contrast; 0<=integer<=100; default=0

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=5.

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

-P process ... PROCESS is the embroidering processing for the background color. The choices are: yes (y), no (n), transparent (t) or preserve (p). If no, the background color will not be emroidered. If transparent, the background color in the output image will be repaced with transparency. If preserve and there is a non-opaque alpha channel, then the alpha channel will be preserved in the output image and process will be reset to yes. If no or transparent options are used, you may need to disable the shadow via -extent and/or -intensity. The default=yes

-a angle ... ANGLE is the initial pattern angle used for the most frequent 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 for IM >= 6.7.9.5; otherwise default=1 (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

-G gain ... GAIN in pattern contrast. Values are 0<=integers<=100. The default=0.

NOTE: The input image should be completely opaque. If not and if a background color is explicitly specified, then any transparency will be flattened against the background color to remove it. Otherwise, the alpha channel will be disabled.

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)



Example 6 -- Variation In Backgrounds

Original
(source)

 

Arguments:
-n 8 -p linear -t 2 -e 2 -P yes

 

Arguments:
-n 8 -p linear -t 2 -e 0 -P no

 

Arguments:
-n 8 -p linear -t 2 -e 0 -P transparent



Example 7 -- Variation In Pattern Contrast

Original

 

Arguments:
-n 2 -p linear -t 2

 

Arguments:
-n 2 -p linear -t 2 -G 10



Example 8 -- Variation In Pointsize Text And Bevel

Original
convert -size 600x300 -background white -fill "#2B6EB5" \
-font Ubuntu-Bold -pointsize 128 -gravity center label:UBUNTU \
-trim +repage -bordercolor white -border 10 ubuntu128.png

 

Arguments:
-n 2 -p linear -t 2 -B 4

 

Arguments:
-n 2 -p linear -t 2 -B 8

 

Arguments:
-n 2 -p linear -t 2 -B 4 -a 45 -P trans

 

Arguments:
-n 2 -p linear -t 2 -B 8 -a 45 -P trans

 

Original
convert -size 600x300 -background white -fill "#2B6EB5" \
-font Ubuntu-Bold -pointsize 64 -gravity center label:UBUNTU \
-trim +repage -bordercolor white -border 10 ubuntu64.png

 

Arguments:
-n 2 -p linear -t 2 -B 4 -a 45 -P trans

 

Arguments:
-n 2 -p linear -t 2 -B 8 -a 45 -P trans

 

Original
convert -size 600x300 -background white -fill "#2B6EB5" \
-font Ubuntu-Bold -pointsize 32 -gravity center label:UBUNTU \
-trim +repage -bordercolor white -border 10 ubuntu32.png

 

Arguments:
-n 2 -p linear -t 2 -B 4 -a 45 -P trans

 

Arguments:
-n 2 -p linear -t 2 -B 8 -a 45 -P trans



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