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

Install rawpy by running:

pip install rawpy

Binary wheels are provided for Linux, macOS, and Windows. Currently, Linux and macOS wheels are only available as 64 bit versions.

Stable vs. pre-release

All stable rawpy releases are always built against a stable LibRaw library release. You can output the LibRaw version with print(rawpy.libraw_version).

rawpy pre-releases have version numbers like 0.15.0a1 and are built against a recent LibRaw snapshot. To install a pre-release, run:

pip install --pre rawpy

Optional features

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.20.0
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.0-cp38-cp38-win_amd64.whl (636.9 kB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.8macOS 10.9+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.7mmacOS 10.9+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.6mmacOS 10.9+ x86-64

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

Uploaded CPython 3.5mWindows x86-64

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

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

rawpy-0.15.0-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.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.15.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 636.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 7592fa527ffc96b0a1fe9f8cc08cdda327d9d53af13a564ff2dc96b035121891
MD5 7b4352f401365df415658d5168338e19
BLAKE2b-256 142cbc4a7f7ae3e1011f88ffc13ad44adb36a88aab21c74c740ce58b61827c38

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9d4fd00f0c905d58b408bfc6970b312eeeafaae50cb680adba5ba266f1040734
MD5 5e500b214cb8b89d93ea386c0fbd394c
BLAKE2b-256 a2c3e81656dd5f13ace97d787076df4437701a690e87e2221304722ae5587157

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 23912534741d0ab9825b43924ae4d273a928fdaa448cb76367e14102af27e16d
MD5 43893b8e344d3476e387d6175d65d545
BLAKE2b-256 b36c4cd0c71c13c658791dc47539ca0428efbcec4f4b5062e5dcd5b2eb86a041

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 633.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 292ecf6c74b90822bde01cef81075483081930f658b44fc863279241bfd1a642
MD5 a1b648fe528b9ee43a30e5c1df9749d3
BLAKE2b-256 02d0fa6b52e6a9e18e07c178d9c7a8c7e600270b2be0c158c09e6dc52b8e4dc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 6dbc127b0215fae99e0c2f9c13b85c51c79f963c08d74183c8bdae9154d81820
MD5 68accd375d52cd49904e7e3db97a6a98
BLAKE2b-256 e23ef5671ef2b5c0c3799569103c8c99289cf22e7883f96ca920275d10ccf2d7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d59be78be67965be77d5c723299fbf5a41ec56a44ff89ec0c90ee571ca4838c7
MD5 891d3512927545c2c4883b4ff2656993
BLAKE2b-256 464c72cb90b976e42af1d84b51c22263408b82195ec0e11bd1f20bf3e63009f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 632.8 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e3b7900c7128cdb93702c7b8357ed09c20f26d640466b3236ba680fbb2f70ca8
MD5 9964849b6cb84a7fea5ba6a37f5462e2
BLAKE2b-256 dc73054e0ee85654bf4d0131a1268a7625f232ab0b0d94e302ee207cbefa7ad6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5da208a583a13081280a90050a365446045cd55c7736d25eedf255ea22aedd71
MD5 d4234d00d18b91415510ecb5b7cc6c11
BLAKE2b-256 fe9877e0661906c1ab20e45bbb45935fe3e114234e4a4efaee945b699df6b897

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 172b41eef1e286685977cfc945add5225d506dc7f29683f6d868100888502046
MD5 14e7dcbea240c0f92968a1b4085bcc9c
BLAKE2b-256 37570224d29e7b1b84832a5cf09bcd7dd8cda51436e47cdfe8a04578a574c29b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 627.6 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 16bbdae479b63371b6f7ed0007840fd9d0fb0e8daf6de455ee55cc9c4a48dbe8
MD5 6991e20bf14b18c6b0489ad4dc553354
BLAKE2b-256 5a159b3a1ebadfcaa100df275baab53cef6e00c6934f3e402e21058659263854

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0897fbc2942197a1e4e6df35d78962851cd42b0ffc4a7c372129fbf1593fb8a1
MD5 0cedf8393c22799a46d23dfa57dd164d
BLAKE2b-256 99f9ab22f2d5e37534327eb3646e780b320b1561a54ecd4af5d233b3471fa24b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.15.0-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for rawpy-0.15.0-cp35-cp35m-macosx_10_9_intel.whl
Algorithm Hash digest
SHA256 980870b31b4b1f69ec89d50e55c6ca7493ca2667c288b9fa27806ed0e23cd3a3
MD5 214ef52dcfc7c03d9368b13dc8c26bb8
BLAKE2b-256 d76c542c68c122e55d4b9c62f06b18594d57b4c08652281e12ba4f210ad18af2

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