Fred's ImageMagick Scripts


    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:

    Please read the Pointers For Use on my home page to properly install and customize my scripts.


Changes the exposure level of an image by photographic stops.

Download Script

last modified: December 16, 2018

USAGE: xposure [-s stops] [-o offset] [-g gamma] infile outfile
USAGE: xposure [-h or -help]

-s ... stops .... exposure gain in photographic stops; float; default=0
-o ... offset ... exposure offset in fractions; floats; default=0
-g ... gamma .... exposure gamma value; float>0; default=1

PURPOSE: To change the exposure level of an image by photographic stops.

DESCRIPTION: XPOSURE changes the exposure level of an image by photographic stops to make it either brighter or darker. Linear changes are made according to output=input*gain+offset. Nonlinear changes are made with gamma. One stop increase/decrease changes the gain by a factor of 2.


-s stops ... STOPS controls the exposure gain. Values are floats. One stop increase/decrease means a doubling/halving of the gain. The default=0 (no change).

-o offset ... OFFSET controls the exposure offset in fractions. Values are floats typically between -1 and 1. The default=0. (no change)

-g gamma ... GAMMA a non-linear change. Values are floats greater than 0. The default=1 (no change)

REQUIREMENT: IM 6.4.8-9 due to the use of -function polynomial.

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.


Example 1 - Change Stops

-s 0.5


-s -0.5

Example 2 - Change Offset

-o 0.1


-o -0.1

What the script does is as follows:

  • converts stops to gain
  • converts the image to linear RGB colorspace
    applies -function polynomial and
    returns the image to non-linear sRGB

This is equivalent to the following IM commands

  • gain=`convert xc: -format "%[fx:pow(2,$stops)]" info:`
  • convert $tmpA1 -colorspace RGB \
    -function polynomial "$gain,$offset" -gamma $gamma \
    -colorspace sRGB $outfile