Skip to main content

Python wrapper for the LibRaw library

Project description

Linux Build Status Mac OS X Build Status Windows Build Status

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.

API Documentation

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, 3.4 and 3.5 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rawpy, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size rawpy-0.5.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 (860.6 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size rawpy-0.5.0-cp27-none-win32.whl (355.0 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size rawpy-0.5.0-cp27-none-win_amd64.whl (397.7 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size rawpy-0.5.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 (859.7 kB) File type Wheel Python version cp33 Upload date Hashes View
Filename, size rawpy-0.5.0-cp33-none-win32.whl (332.3 kB) File type Wheel Python version 3.3 Upload date Hashes View
Filename, size rawpy-0.5.0-cp33-none-win_amd64.whl (371.9 kB) File type Wheel Python version 3.3 Upload date Hashes View
Filename, size rawpy-0.5.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 (860.4 kB) File type Wheel Python version cp34 Upload date Hashes View
Filename, size rawpy-0.5.0-cp34-none-win32.whl (332.4 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size rawpy-0.5.0-cp34-none-win_amd64.whl (371.8 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size rawpy-0.5.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (860.2 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size rawpy-0.5.0-cp35-none-win32.whl (418.6 kB) File type Wheel Python version 3.5 Upload date Hashes View
Filename, size rawpy-0.5.0-cp35-none-win_amd64.whl (470.3 kB) File type Wheel Python version 3.5 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page