Skip to main content

RAW image processing for Python, a wrapper for libraw

Project description

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.v3 as iio

path = 'image.nef'
with rawpy.imread(path) as raw:
    rgb = raw.postprocess()
iio.imwrite('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)
iio.imwrite('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
    iio.imwrite('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()
    iio.imwrite(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.

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.23.2-cp312-cp312-win_amd64.whl (754.4 kB view details)

Uploaded CPython 3.12 Windows x86-64

rawpy-0.23.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

rawpy-0.23.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

rawpy-0.23.2-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rawpy-0.23.2-cp312-cp312-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

rawpy-0.23.2-cp311-cp311-win_amd64.whl (758.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

rawpy-0.23.2-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

rawpy-0.23.2-cp310-cp310-win_amd64.whl (757.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

rawpy-0.23.2-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

rawpy-0.23.2-cp39-cp39-win_amd64.whl (758.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

rawpy-0.23.2-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file rawpy-0.23.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.23.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 754.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rawpy-0.23.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 75fd34b63bed8ed9f585fb8d783b6260c32b45a25c202e812af642dc05837bd7
MD5 08d9a321115ab43255809d71c415d9ef
BLAKE2b-256 7ca3ca5d2eb0175b733d6136c6b4615bdaa3ea03239006b4b79b69af5a4a9a66

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0ce160d06b353769abc5ac6298fbf812d218c49943f1fe9fa97229e8846ca6d
MD5 570d61689f59c2ac538025b164112fd8
BLAKE2b-256 f48678891cd2344e679cf4c7813ec20503a811e77ab230838d1f464d9f2a6a96

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d138c6ebc2796b44d57bbae306ec75076acd0b59091de8b886d1e9e6c30b966b
MD5 f9557b7efc8076be71d6fe5c87c52a6c
BLAKE2b-256 d3118103367c28dd1b15d3720324303d15f3d6960e9888b752c830a182f71496

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5998a4f7cd13236bbde72811dff3a9be7b723ef25078263ecef8ec826328483e
MD5 ebfb0667200ff33e6119ce11d6de375c
BLAKE2b-256 a3627aa7e3768b5220c427489194f472e39021a2ac6b24fe0db0a90949eed1d5

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b4fbda4ba01ee3bde82d3940e025f226c715fc963bb876532d640490de133c0e
MD5 cf6a3ca6894630b98f31c350006e985c
BLAKE2b-256 25e33f8d914b274cd2e98ad2a10e9f6f5a992450e641273c2d0483ca66832310

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.23.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 758.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rawpy-0.23.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cf4790b20a0b27232b9511669e8777d839863efc9acc38e82db87dfec0384b4a
MD5 7cd57a8f58d282490d4c00be41c6e6e3
BLAKE2b-256 43589d8c2c6b1c5dd2b47bb86a4fc5ac1eb6df30f0ce9e6ef3c52bcb85654234

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59c0701667f13d1773f3b6bab60b9a7a6e22ff184d25f4c1d1bfb444fef98914
MD5 02c9df2ec04017ba9c83d862523740f8
BLAKE2b-256 9ed7b9c59abe08bd8b02543d38574c3e428f17f7bb39b3b4e30e13a0652531c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9e58c8d33381e9638f22909554eb442f6043fdc0b475701c424b8ca05afe5d36
MD5 d5446bcbee8b408eec18d2a6298b425a
BLAKE2b-256 66dde918262787413c957c4b50a8d2ddfe50f3510a46930edd4909e3296f9131

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d1e00dea7636031244633606a5ef95f7087c6807f3cecc9829cfe09809c6b99a
MD5 d7264e2f6f877fa92b63ddbd3b6c0354
BLAKE2b-256 d10a95858b5d58f790f14189a716d709c65d6fb3831418464e66c204ebb40275

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dd77b7ad389b47d374b522cb93ff2ed07f54230c92be8c13bfd7a620f7b9c566
MD5 a8531de6f86f85c017ba2b0c3940825a
BLAKE2b-256 c6fca2326c520e1325163dd4709e919bc2102cc9d43e24ac07c6634aaf3fbd96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.23.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 757.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rawpy-0.23.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d00d97f722f42e9e3173eb4446465a77ea2c374b8b3043f2cf6e6e0b893bcc40
MD5 31e2c691dadc8701242d6a616d61dae4
BLAKE2b-256 7b49b876072d58eb63517571760885bd0a6344657e2bed51ef448de651525a03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bc52ce40f68ac07cd44c4239dd0b6effff303ba731587e82d938dc6cb58e5df8
MD5 a4f2ff05c4eb7b644ae09198169903b4
BLAKE2b-256 4390a7c31133bed76363a4180d86cf8640fc370d21b25b04d490975e62366ba8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 80251d3cdfcf04d3d56f3209697a231a730c54e48f0d69acc086a8a47875aefe
MD5 39c9bd992fa850995960085aab1cf97e
BLAKE2b-256 2eb0ff6cf1fe212f8d44ff66287e7b215940fd16c6b81820922f038ec1592596

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14faecb9b69aa4eaea9711e06eb817b716132bb77b47318efd11273d1115f438
MD5 c1cbb4c55ad1000b16b8802f56240480
BLAKE2b-256 38935ef2d37ffa4fc86771bafac0240b2d575064857baa81fc1ef16d263094c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5687a050af9e026c88bff62741214c32c7a4491244fa642c6a1b9807dc18e29c
MD5 9e477386f973f2762012b831206e3f66
BLAKE2b-256 4e0344d0e5532f0dc52f0d53e6333709cfafe855b92ebe11f69445fe49cafe5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.23.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 758.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rawpy-0.23.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 540eac17a50f6d9f84500ba1ec8d4e53472f2ee82293d9af99a7c76fcdf819a2
MD5 39ccaf2c37744b19c2d67ae598bada63
BLAKE2b-256 ead2646cfac186fff28963e90a748b3c418952f78bf764dde8cf42abb7b25c7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5851361e31669f7e08493dd0ed70817ea82db18a74437abf97b44cf02881fd3c
MD5 54a505106aa215ddf41be39c10895f53
BLAKE2b-256 b525f02ce2db35654d5b97a23d18b25bb0bc7ebcc1e7d9b73b668b104b6f765b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6b17f4f7d53b7cf8fc33879a7e36439b6cbac152ab923238245cc1ee010d86cc
MD5 f7ccd32c1bd768756e9b863cfa2401dd
BLAKE2b-256 e7dcd309671ce6fec6ff21f609fcab88845200f804c39960b400874b80d1de98

See more details on using hashes here.

File details

Details for the file rawpy-0.23.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rawpy-0.23.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 490df6aed38a63e01bec71be6c3dcaa8541b23911459f0160cb56d9b745ce74c
MD5 141012a9e37f471566a0cf13e248e372
BLAKE2b-256 1b8d4caf28c705b7780c3f4c3943518ae0a5df5bc900c08585a7d7282ec93259

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 aa2301297d8c95a6b49e41798240c14619f4753fe35f80d565fb303ea95412d1
MD5 ee6fc2e34f59d6b033b1275caf677311
BLAKE2b-256 b36e5038497e269961805cf94d5b9165e74b69bb28ac35420364f38db39f1d1a

See more details on using hashes here.

Supported by

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