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

WOODCUT


Applies a woodcut effect to an image.

Download Script

last modified: June 02, 2015



USAGE: woodcut [-k king] [-p presharp] [-e edge] [-d dither] [-P postsharp]
[-a azimuth] [-i intensity] [-m mix] [-c colors] [-S sat] [-H hue]
infile woodfile outfile

USAGE: woodcut [-h or -help]

-k ... kind ........ kind of woodcut; choices are: burn (b) or carve (c);
.................... default=burn
-p ... presharp .... pre-sharpening amount; float>=0; default=12
-e ... edge ........ amount of edge enhancement; float>=0; default=3
-d ... dither ...... dither percent strength; 0<=integer<=100; default=50
-P ... postsharp ... post-sharpening amount; float>=0; default=0
-a ... azimuth ..... carve azimuth angle for shading; 0<=integer<=360;
.................... counterclockwise from positive x axis (East);
.................... default=135 (NorthWest)
-i ... intensity ... intensity of carve effect; float>=0; default=1
-m ... mix ......... mix percent between processed foreground image and
.................... background woodfile; 0<=integer<=100; default=40
-c ... colors ...... additional colorizing of processed image; comma
.................... separated pair of colors for foreground and background;
.................... default="black,white"
-S ... sat ......... saturation change for background woodfile; integer>=0;
.................... default=125; (100 is no change)
-H ... hue ......... hue change for background woodfile; integer>=0;
.................... default=100 (no change)

The woodfile is any woodgrain texture image that is as large or larger than
the image to be processed. The center region of the woodgrain texture image
will then be cropped out and used for the background image. You may create
the woodgrain texture image using my script, woodgrain, for example.

PURPOSE: To apply woodcut effect to an image.

DESCRIPTION: WOODCUT applies a woodcut effect to an image. The effect is placed over a user supplied background wood texture image. Two kinds of effects are possible: a burn-in like effect and a carved-like effect.

ARGUMENTS:

-k kind ... KIND of woodcut. Choices are: burn (b) or carve (c). The default=burn.

-p presharp ... PRESHARP is the pre-sharpening amount. Values are floats>=0. The default=12.

-e edge ... EDGE is the amount of edge enhancement. Values are floats>=0. The default=3.

-d dither ... DITHER percent strength. Values are integers betwee 0 and 100. The default=50.

-P postsharp ... POSTSHARP is the post-sharpening amount. Values are floats>=0. The default=0.

-a azimuth ... AZIMUTH is the angle in degrees in the x-y plane measured counterclockwise from EAST to the light source used for the carve effect. Values are integers in the range 0 to 360. The default=135 (NorthWest).

-i intensity ... INTENSITY of the carve effect. Values are floats>=0. The default=1.

-m mix ... MIX percent between processed image and woodfile. Values are integers between 0 and 100. The default=40.

-c colors ... COLORS are the colors used for additional colorizing of the processed image. Values are a comma separated pair of colors for foreground and background. The default="black,white".

-S sat ... SAT is the saturation gain to apply to the woodfile. Values are integers>=0. The default=125; (100 is no change).

-H hue ... HUE adjustment vallue for background woodfile. Values are integers>=0. The default=100 (no change)

REQUIREMENTS: IM 6.4.8-8 in order to support -function polynomial in the carve method when intensity is other than one.

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 Dither

Original Image

Cropped Woodgrain Image
(center of 1024x1024 texture)
(woodgrain -d 1024x1024 -m peachpuff -g darkorange4)

Arguments:
-k burn -d 50 (default)

Arguments:
-k burn -d 0

Arguments:
-k burn -d 100



Example 2 - Variation in Pre-Sharpening

Original Image

Cropped Woodgrain Image
(center of 1024x1024 texture)
(woodgrain -d 1024x1024 -m peachpuff -g darkorange4)

Arguments:
-k burn -p 12 (default)

Arguments:
-k burn -p 3



Example 3 - Variation in Post-Sharpening

Original Image

Cropped Woodgrain Image
(center of 1024x1024 texture)
(woodgrain -d 1024x1024 -m peachpuff -g darkorange4)

Arguments:
-k burn -P 0 (default)

Arguments:
-k burn -P 4



Example 4 - Variation in Mix

Original Image

Cropped Woodgrain Image
(center of 1024x1024 texture)
(woodgrain -d 1024x1024 -m peachpuff -g darkorange4)

Arguments:
-k burn -m 40 (default)

Arguments:
-k burn -m 70

Arguments:
-k burn -m 100



Example 5 - Variation in Colorizing

Original Image

Cropped Woodgrain Image
(center of 1024x1024 texture)
(woodgrain -d 1024x1024 -m peachpuff -g darkorange4)

Arguments:
-k burn -c "blackxwhite" (default)

Arguments:
-k burn -c "blackxpeachpuff"



Example 6 - Variation in Kind

Original Image

Cropped Woodgrain Image
(center of 1024x1024 texture)
(woodgrain -d 1024x1024 -m peachpuff -g darkorange4)

Arguments:
-k burn (default)

Arguments:
-k carve -d 50 -i 1

Arguments:
-k carve -d 25 -i 2



Example 7 - Larger Image

Original Image

Arguments:
-k burn (default)



What the script does is as follows:

  • Converts image to grayscale and sharpens it
  • Makes a copy and blurs it
  • Subtracts blurred image from the grayscale sharpened image
  • Add the difference image to the sharpened grayscale image
  • Colorize the result from above and adds the mix amount of transparency
  • Crops the center of woodfile and modulates the sat and hue
  • Puts the transparent image over woodfile

This is equivalent to the following IM commands for kind=burn.

  • convert -quiet -regard-warnings "$infile" +repage "$tmpA1"
  • convert -quiet -regard-warnings "$woodfile" +repage "$tmpB1"
  • dim=`convert $tmpA1 -format "%wx%h" info:`
  • convert $tmpA1 -set colorspace RGB -colorspace gray -sharpen 0x$presharp \
    \( -clone 0 -blur 0x$edge \) \
    \( -clone 0 -clone 1 +swap -compose minus -composite -auto-level \) \
    \( -clone 0 -clone 2 -compose plus -composite \) -delete 0-2 \
    $tmpA1
  • convert $tmpA1 \
    \( -clone 0 \
    \( -size 20x640 gradient: -rotate 90 -colors 2 -colorspace gray -auto-level -write mpr:dither +delete \) \
    -dither Riemersma -remap mpr:dither \) \
    -define compose:args=$dither -compose blend -composite -sharpen 0x$postsharp \
    $tmpA1
  • convert \( $tmpA1 +level-colors $colors -alpha set -channel A -evaluate set $mix% -channel RGBA \) \
    \( $tmpB1 -gravity center -crop ${dim}+0+0 +repage $modulating \) \
    +swap -compose over -composite $outfile