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

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

rawpy-0.23.1-cp312-cp312-win_amd64.whl (851.4 kB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

rawpy-0.23.1-cp311-cp311-win_amd64.whl (854.9 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.23.1-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.23.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.23.1-cp310-cp310-win_amd64.whl (854.8 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.23.1-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.23.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.23.1-cp39-cp39-win_amd64.whl (855.0 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.23.1-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.23.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: rawpy-0.23.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 851.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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a5077ca1cf9661e402748362abb0b4e66740b81f0478cf7f99c7150eb1149d44
MD5 8f26267fc629e6aed21b2899893cf828
BLAKE2b-256 4d690bbcba79bae38d48ce3ab7f333ba46faf1ab0b213dc9b3a0fefbb0fe99e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1fef0e717a956c0b3e4e50709c38c0ec447853ce883ddc2305a2c73948cc533d
MD5 decf67fc65cbf0502032f00658b6b4fe
BLAKE2b-256 73c7436f24e2f354ddc5f2e67b28289ce8d3c599a3a71e4d1098b8fa5346ddf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 86c452cff6d6aad6e871b2956163679f41abd94732fc0295aef5626457d8fcb0
MD5 de151c1ac4a9feec6f25c3fb3fafafa2
BLAKE2b-256 8474ac597a676cd984491d522a7cd3889943d8cbbac81f30d22e10e717afd305

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f412896f17997b5eb6f06332c8abbceaea2fe7c9230382062fdd4acc555fb77
MD5 7eb5a30bd837ed519934c629fbf717b5
BLAKE2b-256 cd73c9af08e615066943f9e4a750185163e125472c29d33dc9a8568f2c70ba9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c36b758a43d695dc9b64ee0614f8441f0b7f2b92a815da99aaa30d1d8dd31208
MD5 81468586d471d2c20c287c7b17d2c9e2
BLAKE2b-256 284594d91785b68817d7de33d5870ede2a90719c258e3b314946a74b79a1fe20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.23.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 854.9 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 08bf5a03ec94983edf37065a8ac3f6efdf464e85e0d3e052ab941fbccd89d998
MD5 cc0efb2dd56d9b3c2c3f017b5ec7e085
BLAKE2b-256 77a63515e5b50fa103333ebee2ca1c5a2c99e70077fe07da296a178f853a156d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 391c6fe448f419e0c36663d52413fc66b7772cb6724fb2d3473ff52cef817895
MD5 61983f8eeb35ce860f8f8a1f776c50e9
BLAKE2b-256 cc7113a9f0fb3850ae679481c023594bfa0f20cc65952ac6bcfccd96814b02f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d1202657ffb51710fa0fb6ae00012648320fc30e6226af92c8b7b78f44bc7e03
MD5 2890b52569736b6b4f36b8163f1effb8
BLAKE2b-256 cf5faa493056db6243b3e3b1660da49157e549d235a96bb24a8738f94ff74b6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5098f3bb560d855ead6554fa6074b43c75bc15d1f801d2e837a327b72c50a3b
MD5 f8e13edd71c6ea167bee12a8ffcec300
BLAKE2b-256 f89550c3d04c0f69430a765998b1df10e52ff133877b5b53220afac0f776aac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b030a10e4c89eef98ef4cb5dda41b210bda00c283838de25add1d1a5aa8ce503
MD5 529f6ff5ff34ebe00009c9c66db3f9ae
BLAKE2b-256 83ca9d015dd2beea741d821db44efa12d6fb153ec3635774c1612d7035961525

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.23.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 854.8 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8ed6ab42051fdde69966091f88dc9284d51dddfca006333f23ddf1d6f79b44e8
MD5 34915f9bdc6c3cb5342e1536fce8e75d
BLAKE2b-256 1c5060f797596de4f274d9354199c88c97d7f995fd306af9c6ea945cc901388b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0aa97213e925283bc88d914203c83e0c2ec565aa6189fa42af8388c53216e09
MD5 981fcf0a0ae095cfe049a249993e151b
BLAKE2b-256 88f332463ff9794eb6e69bfe5cacf71f51a07013288604b00a35c82bb08e4668

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 95b4ab2ad6e53f289ed5137f991a22b7f05ab80c8bd46e83a504b0831c014978
MD5 6f73604eda0e02c401af5388671bba44
BLAKE2b-256 26f91b416494a1ead4bd9ab7415b5d64734df92a3473211446c5f9efff8ea240

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab8a6b4348dd047cb2a77b4e7ec03d6f74acc63610e12541e0749f189dd31f63
MD5 d9f7c010056c1c6163dc920b8b7a37cf
BLAKE2b-256 3f29e47405e8ca5472b8ff172b65af6d735c1330f6f14e63dad07c5a6b60e131

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ef176760c6cf8347fffad83a27f5c40aee27602277393a8031e4939ea7ed620e
MD5 babbdd0900505e9fa392798d7a4a643e
BLAKE2b-256 fd28acede51fdfa0cf65576cf39cd82e566e3acd137ba2e4ffb5ee1bbde4ac0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.23.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 855.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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 da99235c80af8926eb91e7268b0dedc30d7b0cbe6ab8ddb3b23aa4536d134447
MD5 f03784872b387894db39ca198b9f5897
BLAKE2b-256 0b203ff9a203474ebc38d4c75c227b9be4b83ecb96dbef8a0463f5e0970cbe05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7b563dd4b2ea0e17547577253d88497b26a8ecaa17cc72afb40bfa5f19e39b6
MD5 57f6703adc39e7377173c0ba3546bf87
BLAKE2b-256 a1edb0507d17b62635187a348f3cfeb055e8f32fa03db95f6ac6d0288b9dc1aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 55d379b3aa86f25dd7c28c254edbb0d3e077ec736b1e5105e688399dd9cd2e31
MD5 e07f9fc3e659c676a7f2eb36b683f297
BLAKE2b-256 91205292edc42d3712576f6890596436f7904780784e0a6b58330262347abd2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16879658e7839cdfa2579f4a318543c4a44dbf316dc61e7cbb0472c1d90335e6
MD5 969c070ec9b8062d93499909556d3f16
BLAKE2b-256 b11b5be98ead989c66f755c128c724ea8896ab414a6aeba5b0aaf9b11e162712

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.23.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6fbdc64283917e20f66199d057be7ba6cecc690778793e9f7af045a2322d4e8b
MD5 1d4791279155fd5c2156216fe1884d54
BLAKE2b-256 6ef66c7f1aa1269798e572ac389e5a68feb2f13b0347539de88a53147c38e8fd

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