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.15.0a1-cp38-cp38-win_amd64.whl (635.4 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.15.0a1-cp38-cp38-manylinux2010_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

rawpy-0.15.0a1-cp38-cp38-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

rawpy-0.15.0a1-cp37-cp37m-win_amd64.whl (631.1 kB view details)

Uploaded CPython 3.7mWindows x86-64

rawpy-0.15.0a1-cp37-cp37m-manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

rawpy-0.15.0a1-cp37-cp37m-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

rawpy-0.15.0a1-cp36-cp36m-win_amd64.whl (630.9 kB view details)

Uploaded CPython 3.6mWindows x86-64

rawpy-0.15.0a1-cp36-cp36m-manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

rawpy-0.15.0a1-cp36-cp36m-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

rawpy-0.15.0a1-cp35-cp35m-win_amd64.whl (617.8 kB view details)

Uploaded CPython 3.5mWindows x86-64

rawpy-0.15.0a1-cp35-cp35m-manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

rawpy-0.15.0a1-cp35-cp35m-macosx_10_9_intel.whl (1.0 MB view details)

Uploaded CPython 3.5mmacOS 10.9+ Intel (x86-64, i386)

File details

Details for the file rawpy-0.15.0a1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 635.4 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 494b58b4b2ad390b1ad64ae6d732d70ce52466c7c7596b96325bc8a2d862f51d
MD5 04f9a36be2ba7e94776dd3cf728d700c
BLAKE2b-256 6fa7afc3dc9b57f367d44b963f38de70ec7f3d2d55df84baaa344bdb43162bcd

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.8 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 da81f245dfd020ec0110eea21adfd6cf87134adcffa2216c26e3bd9857640c32
MD5 a38a0f370effbcd78c5a3007797927a8
BLAKE2b-256 c2ab4b4c8da60d47dad96da9dd7dac9cecc53a431495fafbd6dd0947f7589cda

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b21863f79109a0833d3adea81246f3d4d3fe885f8f3119411635fe294a988f21
MD5 1a5c3dfc4590adc2c7235a3bc84ebc36
BLAKE2b-256 578ef2c49b7275ea339c6aa86cc705f3b36792d6bd46853882b7dfcedf89f44b

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 631.1 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 84497da5d0fd7410b2a684d020d4a084b6b64722a1b5bd20c7cba36aa5f33d3b
MD5 e12665d2d2b642de4a90ee669dcabba8
BLAKE2b-256 fce60627a392c22dabd6f4973e0f0c1998aff51075e6db1b6553e48571a5dcb5

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.7 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 849903243209c10a38b9fda7696aaf388f57bc56d7a38c2f133cbfe896b40f04
MD5 b1eb0a3f72f620c8e000958d24b536ed
BLAKE2b-256 d9245262afbe5ed9c9b58b938edd3a2ba7073284821d4da957e8a28d15b10e4a

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 38288eaf7abcb393edd43c14959d6a61fa50bb57f71b65daaa546c0ef5c9cd29
MD5 7d2979c57936940c62d57898ca068b18
BLAKE2b-256 7d370841cad9d28cc22fa9941fcb80044cc2bd490ecdb589459191df51ea492e

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 630.9 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 156da52ab382da69644f371d2f016e8614900bb222706cfc8c55547c31d86084
MD5 36590184be8ec2a1d295c547c67ff2bb
BLAKE2b-256 047c97ec45e48f8cee3df5e4f23f65ef43ff390ffbe5b75babf984262118a27e

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.7 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7bdf4913d32618e85a463a5e846f01827677b9342175cd2639caf07edb7f79ee
MD5 782e290f50e6bb5bf02a0070526f18af
BLAKE2b-256 176a0a9bf0b8a078d0004ebb3526bf6bb32273540c7b6a49b5f7a24c40d940f1

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a3e7ef5e67ae3f6ba764296a2354bffcafd110b5c6ff902f4700222b86b080bb
MD5 7463075a0bd5667db473120fb2199964
BLAKE2b-256 7d3fc19a7ade41c1b71b5b82384d38560790c0d998bd5994408f0d086a65c3a2

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 617.8 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 c6418c76594728de6b1bc2a950880e5ef3fb4fee89963a5b5dacb6edd730a1c5
MD5 c2b369a75c2accc983e418c872c5f563
BLAKE2b-256 be57c3d51bc81af91927f35bf22cac8d2adb938a1718c26668b99c014fdb740d

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.7 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.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 704f09f6f0cf57bb9941d88bbaa89ba7ff4b7770833a2fd5a054aa1f8b7f3de2
MD5 1f76313cc1ee09a254324ba99a424dda
BLAKE2b-256 7263f33d87268848f1de243d69c82122fd25b1b175366faa441b417503f1218a

See more details on using hashes here.

File details

Details for the file rawpy-0.15.0a1-cp35-cp35m-macosx_10_9_intel.whl.

File metadata

  • Download URL: rawpy-0.15.0a1-cp35-cp35m-macosx_10_9_intel.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.5m, macOS 10.9+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for rawpy-0.15.0a1-cp35-cp35m-macosx_10_9_intel.whl
Algorithm Hash digest
SHA256 d2ac434f54c4c387c18fac079600c037fa9ddd88dc5e7e7808c72203ef965396
MD5 ab58075db8093df0b3f94d67f9b27bcc
BLAKE2b-256 3915f68d407c6086e816bbc5607f1e67a83b1a8fd1a091790860c0fd71e45eee

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