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'
with rawpy.imread(path) as raw:
    rgb = raw.postprocess()
imageio.imsave('default.tiff', rgb)

Save as 16-bit linear image:

with rawpy.imread(path) as raw:
    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:
    with rawpy.imread(path) as raw:
        rawpy.enhance.repair_bad_pixels(raw, bad_pixels, method='median')
        rgb = raw.postprocess()
    imageio.imsave(path + '.tiff', rgb)

Installation on Windows and macOS

Binaries are provided for Python 2.7, 3.4, 3.5, and 3.6. These can be installed with a simple pip install rawpy (or pip install --use-wheel rawpy if using pip < 1.5).

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 release version from the source repository:

git clone libraw
git clone libraw-cmake
cd libraw
git checkout 0.18.2
cp -R ../libraw-cmake/* .
cmake .
sudo make install

After that, it’s the usual pip install rawpy.

If you get the error “ImportError: 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/
sudo ldconfig

The LibRaw library is installed in /usr/local/lib (if installed manually) and apparently this folder is not searched for libraries by default in some Linux distributions.

NumPy Dependency

rawpy depends on NumPy. The minimum supported NumPy version depends on your Python version:




>= 1.7


>= 1.8


>= 1.9


>= 1.11

Project details

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distributions

rawpy-0.10.0a1-cp36-cp36m-win_amd64.whl (518.8 kB view hashes)

Uploaded 3 6

rawpy-0.10.0a1-cp36-cp36m-win32.whl (450.1 kB view hashes)

Uploaded 3 6

rawpy-0.10.0a1-cp35-cp35m-win_amd64.whl (517.9 kB view hashes)

Uploaded 3 5

rawpy-0.10.0a1-cp35-cp35m-win32.whl (449.3 kB view hashes)

Uploaded 3 5

rawpy-0.10.0a1-cp34-cp34m-win_amd64.whl (356.8 kB view hashes)

Uploaded 3 4

rawpy-0.10.0a1-cp34-cp34m-win32.whl (318.4 kB view hashes)

Uploaded 3 4

rawpy-0.10.0a1-cp27-cp27m-win_amd64.whl (383.7 kB view hashes)

Uploaded 2 7

rawpy-0.10.0a1-cp27-cp27m-win32.whl (341.2 kB view hashes)

Uploaded 2 7

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 NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page