Download OpenEXR-1.2.0.tar.gz.
OpenEXR is an image format developed by ILM. OpenEXR's main advantage over other image formats is high dynamic range: it supports floating point pixels. High dynamic range (HDR) images allow a closer representation of real-world colors: shadow and highlight detail is preserved.
Full documentation is online and as a PDF.
Here is a brief sample that duplicates exrnormalize from exrtools
import sys
import array
import OpenEXR
import Imath
if len(sys.argv) != 3:
print "usage: exrnormalize.py exr-input-file exr-output-file"
sys.exit(1)
# Open the input file
file = OpenEXR.InputFile(sys.argv[1])
# Compute the size
dw = file.header()['dataWindow']
sz = (dw.max.x - dw.min.x + 1, dw.max.y - dw.min.y + 1)
# Read the three color channels as 32-bit floats
FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
(R,G,B) = [array.array('f', file.channel(Chan, FLOAT)).tolist() for Chan in ("R", "G", "B") ]
# Normalize so that brightest sample is 1
brightest = max(R + G + B)
R = [ i / brightest for i in R ]
G = [ i / brightest for i in G ]
B = [ i / brightest for i in B ]
# Convert to strings
(Rs, Gs, Bs) = [ array.array('f', Chan).tostring() for Chan in (R, G, B) ]
# Write the three color channels to the output file
out = OpenEXR.OutputFile(sys.argv[2], OpenEXR.Header(sz[0], sz[1]))
out.writePixels({'R' : Rs, 'G' : Gs, 'B' : Gs })
Prerequisite is Python 2.5 and up, and the OpenEXR C++ library.
For a Debian-based Linux:
sudo apt-get install libopenexr-dev
on MacOS with DarwinPorts:
sudo port install openexr
on BSD there is now a port, py-openexr, so all you need to do is:
cd /usr/ports/graphics/py-openexr sudo make install
Then to install the Python bindings themselves:
easy_install -U openexr
or you can download the above source directory then do:
sudo python setup.py install
OpenEXR-1.2 (Aug 2010)
OpenEXR-1.1
OpenEXR-1.0.3
OpenEXR-1.0.1
OpenEXR-1.0.0
OpenEXR-0.0.4
OpenEXR-0.0.3
OpenEXR-0.0.1
I have yet to implement various OpenEXR features - so if you want something in particular, email me and I will try to get it done.