Fred's ImageMagick Scripts



 

 

EXPOSURE


Changes the exposure level of an image.

Download Script

last modified: June 01, 2009



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