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.

EXPOSURE


Changes the exposure level of an image.

Download Script

last modified: December 15, 2018



USAGE: exposure -a amount infile outfile
USAGE: exposure [-h or -help]

-a amount ..... amount of exposure change in percent; -100<=amount<=100;
............... positive will be brighter and negative will be darker;
............... default=0 (no change)

PURPOSE: To change the exposure level of an image.

DESCRIPTION: EXPOSURE changes the exposure level of an image to make it either brighter or darker. It uses -level 0x(100-amount)% to make it brighter and +level 0x(100+amount)% to make it darker.

ARGUMENTS:

-a amount ... AMOUNT of exposure change in percent. Values are floats between -100 and 100. Positive values increase exposure (make it brighter) and negative values decrease exposure (make it darker darker). The default is zero or no change.

NOTE: This script requires IM 6.4.2-0 or higher due to the use of +level, if making the image darker.

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

Arguments:
-a -20

Original

Arguments:
-a 20



Example 2

Arguments:
-a -15

Original

Arguments:
-a 15



What the script does is as follows:

  • checks the sign of the amount
  • if positive, applies -level 0x(100-amount)
  • if negative, applies +level 0x(100+amount)

This is equivalent to the following IM commands

  • sign=`convert xc: -format "%[fx:sign($amount)]" info:`
  • if [ "$amount" = "0" -o "$amount" = "0.0" ]; then
  • operation=""
  • elif [ "$sign" = "1" -o "$sign" = "+1" ]; then
  • amount=`convert xc: -format "%[fx:100-$amount]" info:`
  • operation="-level 0%x${amount}%"
  • elif [ "$sign" = "-1" ]; then
  • amount=`convert xc: -format "%[fx:100+$amount]" info:`
  • operation="+level 0%x${amount}%"
  • fi
  • convert $infile $operation $outfile