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

64-bit binary wheels are provided for Linux, macOS, and Windows.

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 yes yes yes
RedCine codec yes 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 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:USE_CONDA = '1'
$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 four environment variables. Set USE_CONDA = '0' to build within an existing Python environment.

NumPy Dependency

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

Python NumPy
3.7 >= 1.14
3.8 >= 1.17
3.9 >= 1.19
3.10 >= 1.21
3.11 >= 1.23

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.18.0-cp311-cp311-win_amd64.whl (791.2 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.18.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rawpy-0.18.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

rawpy-0.18.0-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.18.0-cp310-cp310-win_amd64.whl (791.8 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.18.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rawpy-0.18.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

rawpy-0.18.0-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.18.0-cp39-cp39-win_amd64.whl (793.6 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.18.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

rawpy-0.18.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

rawpy-0.18.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

rawpy-0.18.0-cp38-cp38-win_amd64.whl (794.5 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.18.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

rawpy-0.18.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

rawpy-0.18.0-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

rawpy-0.18.0-cp37-cp37m-win_amd64.whl (791.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

rawpy-0.18.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

rawpy-0.18.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ARM64

rawpy-0.18.0-cp37-cp37m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

Details for the file rawpy-0.18.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.18.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 791.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for rawpy-0.18.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3d66bd67f37ad68d947336a37137f2717f28ee13200aa0ea51ee7cddffdd8570
MD5 f2f55db419e3a71e0bcdfeae1810617c
BLAKE2b-256 3a05dbf90df322c557180ea26ff146596470f555ec1fd3c2cc878a6a8dcbd34e

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d1282f2c0b59fe1fc95f1e8ff51d9915ee2d3f85431345550860693b9692eab9
MD5 bcc76f0818b771e2cd2b9a6495050eec
BLAKE2b-256 eef01d5bafc32c8ba07dd9be7e5c09f889d1779236e9704f031217254b183044

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 52ff86dd8150aedea306fbd633510d7c49fba9df767b681091babc59a70da5c4
MD5 1f01fa5e2887379b3bfed9903d558602
BLAKE2b-256 a877d76978de542cd9aadcb35ebb783ad0d41ad112fb53be41f51bb095e01fd9

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c60c3f5c4ea4229baa9d3a02f1205539e0ff9a1650d22c6f9cef4fdaefc5c1e
MD5 0ef70434d867959ca2b7628eb04652d1
BLAKE2b-256 83f9dac48dbe50ff7abb76733ce5aa16dc0a37bcb2afc4ea4023b96a68bd92bc

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.18.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 791.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for rawpy-0.18.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b8d7af8d0ab58c049d208ee92e8404331bacb5f6e1c2912e856f9ed831a05572
MD5 05739d00048eefa01e6e8914512003e5
BLAKE2b-256 1ff6353fa1f9fb31e5c98ec953133ca92c55bba05335535a5ec346ea8ccb103d

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2966e0e8005c2bce1ca44dd342dc073ed5b7ef5591c97b86cafa65397c3f382
MD5 46aef0539d094d01e99b801e41ac89be
BLAKE2b-256 0c09b6dbec618f9735e2c547ffe8e5fe869d729cf3e19bb93d4c1810e5b1cb9f

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f6816c395deb842072eb7937794b515ab88335df711ea5c5a74486f7fad31c34
MD5 27ec56556ead54b58d6955f499d0330f
BLAKE2b-256 5d72b33c883465b71461373e96e7b1411ea212ee2cd102bbaf3f801623be0a42

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9d18fa393257cb731b9bc9a1d4fcb4e40f0c8c3dbf735adce366442edb5b2f32
MD5 def5c17baa2229df50ffeb6cd9c9c650
BLAKE2b-256 67adad7d8fe8d75b73b9be6b464d593d90ed3f2530ee0f83c955fb31f0262ed7

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.18.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 793.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for rawpy-0.18.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8f07f9366e20651cf49dc029c69f46c26d6a50b2b78b4a99a0caad2b87861825
MD5 43a7d322cf3bd5e025021af4b77296ad
BLAKE2b-256 844d6368d4ad9140a564d5a50d31d596235f2721809dbb20b7edc2d7582e5dad

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 115c0f05184ee0273afccae39ef658f89e58edb39fd60198cc60f0fb4692609b
MD5 431501cb77c045028b6d4d16dc582a0f
BLAKE2b-256 8c3d75c5faf505687bda7eda0927d163f9e978f055fb3ee9369999be302255d2

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 51a7b39b534e22aaa716da41a0dab62457e26d3da6490b84b59a0054ffc4529e
MD5 1f73ef08fcd4e4b7c84c073701596aab
BLAKE2b-256 b1196082900420d50bfff6c199f45c5c75c9e36e94aa49f879721f80af23234f

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9b4f5e5b38af08c1d9c01f04cfccbb472633e2fe9a0f4b0ea2e3aa847890daae
MD5 519637c20f3ce661550d19596a1b6982
BLAKE2b-256 c5e058f89145e928cdd11fdf57ff5171cd98f30a2a7ed073a65332ad4303a496

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.18.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 794.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for rawpy-0.18.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b3230514c220f44bea3e8abb229836c67c46ff96bca67b408141b01eb2e73908
MD5 231e69ab7c3727fd4d1e35aafd3dbd04
BLAKE2b-256 e1e236abba097b64ad2907eff76f445d0335f35cc11892fbc4bbbde934a1d57f

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 828703186a4f420c9f03ae271f6caa1458cd5ecc7a1f6a51bf8fad45a074f88d
MD5 e8dc5d8649941dafa1536e8679678809
BLAKE2b-256 767e6eafdb6eae58c803ec82c5b8ab8111eb38c850284db3d438dccde710d61d

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 df68580994bd68e9f5935b9778f07745a0845fa0f52f716bd7532570ef156ada
MD5 5148714b097fb216970e21ebb6ceec01
BLAKE2b-256 466f7420c4ca78e42573311241fc282b06a00d1f75b6d4a302aa01f065e468da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1a90395ffb51fe2fb4186d7a9724cb893fbbfb3aaa51807e2dfec81e6a70566b
MD5 6f153165744a9840d71f261c170460c6
BLAKE2b-256 802213abc91f79b9dbb3fcf6f897fd5b7fe082a84551607bd4bbe30d0024a849

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.18.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 791.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for rawpy-0.18.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d000a9b232225220ff3ad89478d474e191e741bc2bdd2761c609ae0221e72372
MD5 58e711d1e42a7e757faa9c40c803f6b8
BLAKE2b-256 69ade5e285cf2d60b9df83ef1dd45f54b78eebcaf52b7860011eee9b747f4fcc

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bfea2755593ec2f357db3d1977080394b8191ee2d850956b3ae01ebb4684cde
MD5 269b4ae019ea9ceca70529d8554f2503
BLAKE2b-256 3f71f3c4ee59eccb6a5f1bb5a90a2fef6fc23fb5e00a018d881f5812db78d419

See more details on using hashes here.

File details

Details for the file rawpy-0.18.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b4b3364cfe181c1e55a49e7fdc56e19601c1948e4294ed422ba3a8d5254241fc
MD5 da43b7488d214412b05fd6cdc42ee394
BLAKE2b-256 2e403648c31d62ff4625b3104037d888a9dc222427a6464dae84ac0e43a4f87f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7264894e625154e3d8db3e7caefbaa5b89738d159649867dc80d86ac0450739f
MD5 5fc12c48f3a05453fe20f04ce3ea08d3
BLAKE2b-256 dc87abd20aac10552dc26668faf22f6b72b943471bdd202e3b3a43ffbf400b3b

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