Skip to main content

RAW image processing for Python, a wrapper for libraw

Project description

rawpy

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

Jupyter notebook tutorials

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)

Extract embedded thumbnail/preview image and save as JPEG:

with rawpy.imread(path) as raw:
    # raises rawpy.LibRawNoThumbnailError if thumbnail missing
    # raises rawpy.LibRawUnsupportedThumbnailError if unsupported format
    thumb = raw.extract_thumb()
if thumb.format == rawpy.ThumbFormat.JPEG:
    # thumb.data is already in JPEG format, save as-is
    with open('thumb.jpeg', 'wb') as f:
        f.write(thumb.data)
elif thumb.format == rawpy.ThumbFormat.BITMAP:
    # thumb.data is an RGB numpy array, convert with imageio
    imageio.imsave('thumb.jpeg', thumb.data)

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

Binary wheels for Linux, macOS, and Windows are provided for Python 3.5 - 3.8. These can be installed with a simple pip install rawpy. Currently, Linux and macOS wheels are only available as 64 bit versions.

The underlying LibRaw library supports several optional features. The following table shows which PyPI binary wheels support which features.

Feature Windows macOS Linux
LCMS color engine no yes yes
RedCine codec no yes yes
DNG deflate codec yes yes yes
DNG lossy codec yes yes yes
Demosaic Pack GPL2 no no no
Demosaic Pack GPL3 no no no
OpenMP yes no yes

Tip: You can dynamically query supported features by inspecting the rawpy.flags dictionary.

Note on Windows features: The LCMS color engine and RedCine codec features are currently not supported as the automated build process to generate wheels relies on Anaconda to supply any needed library dependencies. For RedCine codec support, the Windows variant of the Jasper library is missing, and for LCMS color engine support, the LCMS library is missing.

Note on GPL demosaic packs: The GPL2 and GPL3 demosaic packs are not included as rawpy is licensed under the MIT license which is incompatible with GPL.

Installation from source on Linux/macOS

For macOS, LibRaw is built as part of the rawpy build (see external/). For Linux, you need to install the LibRaw library on your system.

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 https://github.com/LibRaw/LibRaw.git libraw
git clone https://github.com/LibRaw/LibRaw-cmake.git libraw-cmake
cd libraw
git checkout 0.19.5
cp -R ../libraw-cmake/* .
cmake .
sudo make install

After that, install rawpy using:

git clone https://github.com/letmaik/rawpy
cd rawpy
pip install numpy cython
pip install .

On Linux, 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 (if installed manually) and apparently this folder is not searched for libraries by default in some Linux distributions.

Installation from source on Windows

These instructions are experimental and support is not provided for them. Typically, there should be no need to build manually since wheels are hosted on PyPI.

You need to have Visual Studio installed to build rawpy.

In a PowerShell window:

$env:PYTHON_VERSION = '3.7'
$env:PYTHON_ARCH = '64'
$env:NUMPY_VERSION = '1.14.*'
git clone https://github.com/letmaik/rawpy
cd rawpy
.github/scripts/build-windows.ps1

The above will download all build dependencies (including a Python installation) and is fully configured through the three environment variables.

NumPy Dependency

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

Python NumPy
3.5 >= 1.9
3.6 >= 1.11
3.7 >= 1.14
3.8 >= 1.17

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

If you're not sure about the file name format, learn more about wheel file names.

rawpy-0.14.0-cp38-cp38-win_amd64.whl (577.6 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.14.0-cp38-cp38-manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

rawpy-0.14.0-cp38-cp38-macosx_10_9_x86_64.whl (966.7 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

rawpy-0.14.0-cp37-cp37m-win_amd64.whl (573.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

rawpy-0.14.0-cp37-cp37m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

rawpy-0.14.0-cp37-cp37m-macosx_10_9_x86_64.whl (963.6 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

rawpy-0.14.0-cp36-cp36m-win_amd64.whl (573.2 kB view details)

Uploaded CPython 3.6mWindows x86-64

rawpy-0.14.0-cp36-cp36m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

rawpy-0.14.0-cp36-cp36m-macosx_10_9_x86_64.whl (966.4 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

rawpy-0.14.0-cp35-cp35m-win_amd64.whl (559.9 kB view details)

Uploaded CPython 3.5mWindows x86-64

rawpy-0.14.0-cp35-cp35m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

rawpy-0.14.0-cp35-cp35m-macosx_10_9_x86_64.whl (951.6 kB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

Details for the file rawpy-0.14.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 577.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0fe87f10cad688d834130103405359aaf64ceb2087d0a7feea2c7f57e9466cba
MD5 66482ea51fa68aa1e74c161eb86c1a8a
BLAKE2b-256 df59bdac1815d3d4d36a0505939e6d180bd21cbfbf05d35010bf9114f96e912f

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b65b382b3ab0e11965660bf5fe000b9340ca44748409066a3070c9297b95769c
MD5 fc0acf0a1fecf90f06052760dec83684
BLAKE2b-256 75e612b0d2d0b04a10c9fdbea02d4f4b9ed0f6334d6ff6f24f3388c2a844df22

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 966.7 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f7ad875acc7c58b98b5e051d2e2360180ea2d28c8ab2e86585e2fd6edc85151d
MD5 8cad67fdc7c419354f274ff381093b96
BLAKE2b-256 4b007bde16962afb73335085e56727b2bd462a10f9f673962b75a475b2873e8d

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 573.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a96ce12f11299f4e985b58acd2fac57b328c379880366c9362beb3fe294fd3d7
MD5 7cd83dcf4f5f19c709e663c601597a4c
BLAKE2b-256 654aaaa447b88483deddd3261d926fe3cdb81a6f95660df50dd32fc73e0ebee0

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a7675e2888323e3ae303e0b520cd9105dfb0b96e6fff000b49e98242a0308341
MD5 b8c15e95b1f1b14bf848c218105cfece
BLAKE2b-256 adce26ddd7ee3a49bd892fc1b6ac94992c9dab7ab98097315372126e2eec35f1

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 963.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1b115494e2045da37fcaec4f499670da83e62ddb68c785e06b3bb38a0b160daf
MD5 9453a89304876166f77df989565f3add
BLAKE2b-256 377d6b683eb3bc1ffc332e68c61fc18c1609149927adbe0fcd5a3391836f89ac

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 573.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a642bdab61bae16aa722395bd00992d03f4e8bf4e685bbc46956735546a58613
MD5 4894baaf8a5754695be0fb11dd18acd7
BLAKE2b-256 8374d6c33707edd471bfe1a0d87a31927a70b6586c1e88ff9a967f58be487b65

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 da8b426bf87d61ed9514235a83fa762db54072959526727ceaf282f505855ca6
MD5 96d36ae884a78f02bba22e98882c2947
BLAKE2b-256 535013dd9863a3e30b10f15e5abe7c1545db24a78cfe820c342978ae5d87e8c3

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 966.4 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74b78f66a6045ad457a97f8a80249d83810fa4728b48cbdade603f882432638e
MD5 91051ef930c1f78d0414deab8c7536dc
BLAKE2b-256 8d25eca38d6a1e6c48e28f23defef7a55413f1128f2b2a3b6c73ada2417ba92c

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 559.9 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 6ffa1c58bbaaf1dd4f6fc0fa085875e707a129104b2ccacf338dc821fedfb744
MD5 9018aabf66372df19186bd08e9a9da08
BLAKE2b-256 bb5caa1d17f70001f68c7a1e7bde35ae0465d38afb2bcadd2850f2b0ffd8c080

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7c375d572f10bfe3a79cbe46d951701f232018edd510f90824fba6aff020a196
MD5 24733a1a6ef1fb539493067b460e4047
BLAKE2b-256 849620f8d2f7d98189e5d82e04a92a83f9ca9c074b1b4d2e45399830e0c5b266

See more details on using hashes here.

File details

Details for the file rawpy-0.14.0-cp35-cp35m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.14.0-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 951.6 kB
  • Tags: CPython 3.5m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for rawpy-0.14.0-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e47e46553832f64eeaec6a5e862a09280ec9e4fc517012eb122445ae0088e36d
MD5 99e74f8c016be3996f4b0694fa9cb467
BLAKE2b-256 d6ff731eb5cc18ef2b19f35713c4af8c44f541d83b112f63ad799985fc344964

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page