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.

WOODBRAND


Creates a branded effect in a wood grain image using a binary image as the brand.

Download Script

last modified: December 16, 2018



USAGE: woodbrand [-b blur] [-m motionblur ] [-n negate] [-B brighness] [-S saturation] [-H hue] infile bgfile1 [bgfile2] outfile

USAGE: woodbrand [-help]

-b ... blur ......... inner blur amount; integer>=0; default=5
-m ... motionblur ... motionblur amount; integer>=0; default=10
-n ... negate ....... negate (invert) the binary input image; yes or no; default=no
-B ... brightness ... brightness amount; integer>=0; default=100 (no change)
-S ... Saturation ... saturation amount; integer>=0; default=100 (no change)
-h ... hue .......... hue amount; integer>=0; default=100 (no change)

infile is a binary image where white will produce the branding
bgfile1 is the background wood grain image
bgfile2 is an optional background wood grain image used in the branded area

.

PURPOSE: To create a branded effect in a wood grain image using a binary image as the brand.

DESCRIPTION: WOODBRAND creates a branded effect in a wood grain image using a binary image as the brand. The white part of the binary input image will be the branded area in the wood grain bgfile1. An optional bgfile2 may be used for the branded region. The blur provides a symmetric inner blur. The motion blur adds a directional blur to add a lighting effect. The brighntess, saturation and hue modify the wood grain bgfile1 to darken it for the brand. Alternately, an optional second, bgfile2, may be used to change the texture and color in the branded area in place of the brightness, saturation and hue.

ARGUMENTS:

-b blur ... BLUR is the inner blur amount. Values are integers>=0. The default=5.

-m motionblur ... MOTIONBLUR amount. Values are integers>=0. The default=10.

-n negate ... NEGATE (invert) the binary input image. The choices are: yes (y) or no (n). The default=no.

-B brightness ... BRIGHTNESS amount for the branded area. Values are integers>=0. The default=35. A value of 100 is no change.

-S Saturation ... Saturation amount for the branded area. Values are integers>=0. The default=100 (no change).

-h hue ... Hue amount. Values are integers>=0. The default=100 (no change). Values vary between 0 and 200 for a full 360 degree hue change. Values larger than 100 shift the hue towards green and values smaller than 100 shift the hue towards the blue.

NOTE: This script is not designed for images with transparency.

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 Image
(source)

Original Background Image

Arguments:
-b 5 -m 10 -n yes -B 40 -S 100 -H 100
Arguments:
-b 5 -m 10 -n yes -B 40 -S 100 -H 80


Example 2

Original Image
(source)

Original Background Image 1

Original Background Image 2

Arguments:
-b 5 -m 10 -n yes -B 110 -S 100 -H 100
Arguments:
-b 5 -m 10 -n yes -B 110 -S 100 -H 90


What the script does is as follows for one bgfile:

  • Read input and negate as desire and save as mpr: format.
  • Get the dimensions of the input
  • Make a copy and blur and apply motion-blur
  • Composite the blurred copy with the original and delete the blurred copy
  • Put the composite into the alpha channel of the input
  • Read the bgfile and write it to mpr: and modulate it
  • Multiply the two images
  • Put the original image into the alpha channel of of the multiplied result
  • Composite the previous image over the mpr: of the bgfile
  • Write the output

  • convert -quiet "$infile" +repage $tmpA1
  • dims=`convert -ping $tmpA1 -format "%wx%h" info:`
  • if [ "$negate" = "yes" ]; then
    negating="-negate"
    else
    negating=""
    fi
  • convert $tmpA1 $negating -write mpr:img \
    \( -clone 0 -blur 0x$blur -auto-level -level 50x100% \
    -background black -motion-blur 0x${motionblur}-135 \) \
    \( -clone 0,1 -compose multiply -composite \) \
    -delete 1 \
    +swap -alpha off -compose copy_opacity -composite \
    \( "$bgfile1" -resize "$dims^<" +write mpr:back1 \
    -define modulate:colorspace=HSB -modulate $brightness,$saturation,$hue \) \
    -compose multiply -composite \
    mpr:img -alpha off -compose copy_opacity -composite \
    mpr:back1 +swap -gravity center -compose over -composite \
    "$outfile"