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.

PEELINGPAINT


Applies a peeling paint effect to an image.

Download Script

last modified: December 15, 2018



USAGE: peelingpaint [-m mode] [-s strength] [-g gain] infile texture outfile
USAGE: peelingpaint [-h or -help]

-m ... mode ....... mode for output; choices are: cracks (c) or scratches (s);
................... default=cracks
-s ... strength ... strength (darkness) of cracks; integer>=0; default=100
-g ... gain ....... gain applied by composite mask; 0<=integer<=100;
................... default=75

PURPOSE: To apply a peeling paint effect to an image.

DESCRIPTION: PEELINGPAINT applies a peeling paint effect to an image by compositing with a peeling paint texture image. There are two modes. The first is all cracks. The second (scratches) is a mix of dark cracks and light scratches.

ARGUMENTS:

-m mode ... MODE for output. The choices are: cracks (c) or scratches (s). Mode=cracks will be dark cracks. Mode=scratches will be some very dark cracks and bright scratches. The default=cracks.

-s strength ... STRENGTH (darkness) of cracks. Values are integers>=0. The default=100. This argument brightens/darkens the texture image (using -evaluate pow).

-g gain ... GAIN applied by mask. Values are 0<=integer<=100. The default=75. This argument brightens/darkens the composite mask used to control the mixing of the image and texture (using -white-threshold).

NOTE: Both strength and gain produce darkening or lightening of the cracks. My nominal mode of operation is to set the strength to 100. Then adjust the gain to a value that produces cracks that are strong but do not add other artifacts to the image. Then I reduce the strength to create less cracks if desired.

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

Original

Texture
(processed from source)

Arguments:
-m cracks -s 100 -g 75

Arguments:
-m scratches -s 100 -g 75

Arguments:
-m cracks -s 130 -g 75

Arguments:
-m scratches -s 130 -g 75

Arguments:
-m cracks -s 50 -g 75

Arguments:
-m scratches -s 50 -g 75



Example 2

Original

Texture
(processed from source)

Arguments:
-m cracks -s 100 -g 50

Arguments:
-m scratches -s 100 -g 70

Arguments:
-m cracks -s 130 -g 50

Arguments:
-m scratches -s 130 -g 70

Arguments:
-m cracks -s 50 -g 50

Arguments:
-m scratches -s 50 -g 70



What the script does is as follows:

  • Reads the image and texture
  • Modifies the texture image with a non-linear brightness function
  • Negates and modifies the texture image with white-thresholding
  • Composites the 3 images using either bumpmap or hardlight
  • Saves the output

This is equivalent to the following IM commands.

  • dim=`convert $tmpA1 -format "%wx%h" info:`
  • gain=$((100-gain))
  • if [ "$strength" = "100" ]; then
    strengthen=""
    else
    strength=`convert xc: -format "%[fx:$strength/100]" info:`
    strengthen="-evaluate pow $strength"
    fi
  • [ "$mode" = "cracks" ] && cmethod="bumpmap"
  • [ "$mode" = "scratches" ] && cmethod="hardlight"
  • convert $infile \
    \( $texturefile -resize ${dim}\^ -gravity center -crop ${dim}+0+0 +repage $strengthen \) \
    \( +clone -negate -white-threshold $gain% \) \
    -compose $cmethod -composite $outfile