rawpy is an easy-to-use Python wrapper for the LibRaw library. It also contains some extra functionality for finding and repairing hot/dead pixels.
Sample code
Load a RAW file and save the postprocessed image using default parameters:
import rawpy
import imageio
path = 'image.nef'
raw = rawpy.imread(path)
rgb = raw.postprocess()
imageio.imsave('default.tiff', rgb)
Save as 16-bit linear image:
rgb = raw.postprocess(gamma=(1,1), no_auto_bright=True, output_bps=16)
imageio.imsave('linear.tiff', rgb)
Find bad pixels using multiple RAW files and repair them:
import rawpy.enhance
paths = ['image1.nef', 'image2.nef', 'image3.nef']
bad_pixels = rawpy.enhance.find_bad_pixels(paths)
for path in paths:
raw = rawpy.imread(path)
rawpy.enhance.repair_bad_pixels(raw, bad_pixels, method='median')
rgb = raw.postprocess()
imageio.imsave(path + '.tiff', rgb)
Installation on Linux
You need to have the LibRaw library installed to use this wrapper.
On Ubuntu, you can get (an outdated) version with:
sudo apt-get install libraw-dev
Or install the latest developer version from the SVN repository:
git clone git://github.com/LibRaw/LibRaw.git libraw
git clone git://github.com/LibRaw/LibRaw-cmake.git libraw-cmake
cp -R libraw-cmake/* libraw ;
cd libraw
cmake .
sudo make install
After that, it’s the usual pip install rawpy.
If you get the error “ImportError: libraw.so: cannot open shared object file: No such file or directory” when trying to use rawpy, then do the following:
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/99local.conf
sudo ldconfig
The LibRaw library is installed in /usr/local/lib and apparently this folder is not searched for libraries by default in some Linux distributions.
Installation on Windows and Mac OS X
Binaries are provided for Python 2.7, 3.3 and 3.4 for both 32 and 64 bit. These can be installed with a simple pip install --use-wheel rawpy (or just pip install rawpy if using pip >= 1.5).
Binaries for other Python versions are currently not produced but if there is a need then this is possible as well. In that case, just contact me.
Release files for rawpy 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| rawpy-0.4.0-cp34-none-win_amd64.whl | CPython 3.4 | none | Windows x86-64 | Details |
| rawpy-0.4.0-cp34-none-win32.whl | CPython 3.4 | none | Windows x86-32 | Details |
| rawpy-0.4.0-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl | CPython 3.4 | CPython 3.4 pymalloc | macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386), macOS 10.10+ x86-64 | Details |
| rawpy-0.4.0-cp33-none-win_amd64.whl | CPython 3.3 | none | Windows x86-64 | Details |
| rawpy-0.4.0-cp33-none-win32.whl | CPython 3.3 | none | Windows x86-32 | Details |
| rawpy-0.4.0-cp33-cp33m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl | CPython 3.3 | CPython 3.3 pymalloc | macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386), macOS 10.10+ x86-64 | Details |
| rawpy-0.4.0-cp27-none-win_amd64.whl | CPython 2.7 | none | Windows x86-64 | Details |
| rawpy-0.4.0-cp27-none-win32.whl | CPython 2.7 | none | Windows x86-32 | Details |
| rawpy-0.4.0-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl | CPython 2.7 | none | macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386), macOS 10.10+ x86-64 | Details |
Total release size: 5.4 MB
Release files / rawpy-0.4.0-cp34-none-win_amd64.whl
| Download URL | rawpy-0.4.0-cp34-none-win_amd64.whl |
|---|---|
| Size | 476.8 kB |
| Tags | CPython 3.4 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ca0bfc3eb410b9208af02e76fa7e59b9ad073bb9094cf88d5dc021fe3b019aeb
|
|
BLAKE2b-256 checksum How to use checksums |
9b00701a0e1264c565e05ddb273ca39a2acab04d07497c48cef3ffafc7ad3c0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp34-none-win32.whl
| Download URL | rawpy-0.4.0-cp34-none-win32.whl |
|---|---|
| Size | 435.9 kB |
| Tags | CPython 3.4 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
a7a169e3e19422a08cfcf7aa183e6f3423abfb45a0d9a7da47ab3517bc16f936
|
|
BLAKE2b-256 checksum How to use checksums |
d221d1e06985e57addb7c2354eced860a90b95e5d2160081a2c36b43f97678e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
| Download URL | rawpy-0.4.0-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl |
|---|---|
| Size | 859.4 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
e68c9697bf5c3c23249da04114ca424c9b5ac2efd86d5838b21522ef6b0c5726
|
|
BLAKE2b-256 checksum How to use checksums |
edd2792da270263e5997dd7185688e86fa844d66c520504805a6c19b1a17715f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp33-none-win_amd64.whl
| Download URL | rawpy-0.4.0-cp33-none-win_amd64.whl |
|---|---|
| Size | 476.8 kB |
| Tags | CPython 3.3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
843cb55c3c0b705eda307071bce104a5988dedcdd113cbf5d6d198baa3a8df21
|
|
BLAKE2b-256 checksum How to use checksums |
1697eb1d2b829950f8b162a314233210de8ffadde5898c7de0d96e870991d6b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp33-none-win32.whl
| Download URL | rawpy-0.4.0-cp33-none-win32.whl |
|---|---|
| Size | 435.9 kB |
| Tags | CPython 3.3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
71f9392181f06042a0db39e6ed30d7a8a67f513e1f54784273004ab4244630ad
|
|
BLAKE2b-256 checksum How to use checksums |
3f75b7ee78df740141b60b3228b268ef36f5cdac1d8186675b9a38a0b4ae352f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp33-cp33m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
| Download URL | rawpy-0.4.0-cp33-cp33m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl |
|---|---|
| Size | 858.6 kB |
| Tags | CPython 3.3 CPython 3.3 pymalloc macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
6e4970b6532f97a2a89dad715602bdf8a96a78b74f8a70b064826093585da5d2
|
|
BLAKE2b-256 checksum How to use checksums |
142168957207a80e2876402feeff1c3a0a00abe421b84f34a1a5a3a5794d3e54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp27-none-win_amd64.whl
| Download URL | rawpy-0.4.0-cp27-none-win_amd64.whl |
|---|---|
| Size | 503.9 kB |
| Tags | CPython 2.7 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ce6cdf91a4b219b83808c7baa758a4f20ccba508579821904a26cc69b2e46fc2
|
|
BLAKE2b-256 checksum How to use checksums |
ca80160af30375ea94e9502667671c01c6001910259a3c2a154b182246c5cbfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp27-none-win32.whl
| Download URL | rawpy-0.4.0-cp27-none-win32.whl |
|---|---|
| Size | 458.8 kB |
| Tags | CPython 2.7 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
98184142f5e04aa3a13a80c2bf8854ba8967778a222a57009047b6fdbfdc8a7e
|
|
BLAKE2b-256 checksum How to use checksums |
0d61f069892411c92ed540b3155d31ef9b94486e9be38fb72d4cd36d565fceee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rawpy-0.4.0-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
| Download URL | rawpy-0.4.0-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl |
|---|---|
| Size | 859.5 kB |
| Tags | CPython 2.7 macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
5a2b3ea236a8759d7db6183a3794427738f6c1f71366f27fdd47d4be71b6d4d0
|
|
BLAKE2b-256 checksum How to use checksums |
ce6fd99ca6966240db870ff02f8b574ebcb619b0af88383ca89c7c0069ffdc0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |