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

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.

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

Uploaded CPython 3.12Windows x86-64

rawpy-0.20.0-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.20.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

rawpy-0.20.0-cp312-cp312-macosx_11_0_arm64.whl (986.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

rawpy-0.20.0-cp311-cp311-win_amd64.whl (854.2 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.20.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.20.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.20.0-cp311-cp311-macosx_11_0_arm64.whl (989.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.20.0-cp310-cp310-win_amd64.whl (854.0 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.20.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.20.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.20.0-cp310-cp310-macosx_11_0_arm64.whl (989.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.20.0-cp39-cp39-win_amd64.whl (854.0 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.20.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.20.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.20.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

rawpy-0.20.0-cp38-cp38-win_amd64.whl (855.8 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.20.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.20.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.20.0-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: rawpy-0.20.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 850.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.20.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ccfdfbd74313bab89e016ed7834642c190b03a3a3d78308dab356ae3f81943cf
MD5 355652b5fa4724a6efce4dd3eac62b3d
BLAKE2b-256 118e3c3ce60485529d8055593058aaa0a358f83eef0998bd757855ea9f09e6a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2724a3b3c7c3f7fb9e1925c14d3cd85674b33f1bff28f888e5faff561cba5437
MD5 719cf48a36fef0d7941be666994f6408
BLAKE2b-256 4970a9486c2a9fe9a1558496acc7d3fce8c1417f5edbc093298d052ca35de740

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d087f411bf6da94e25eedcaa0c5e3a1366063b85878ade1ec27eb75ec3999980
MD5 f4a995168374931d1d8ee0abe02adcbb
BLAKE2b-256 24b4e0f49ebaacd1fc3241d52dd39b55c8c6007158442221c1534678b8e77809

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bf04e03042cb2a4209a271de1c7cd6c5249783ec3414d8e29558a9f010b9eb7
MD5 21092d18385da9b22be27ada8065f3b8
BLAKE2b-256 f3de6151b7b3f2413e86043d4f46723104b4088b3d8e22651f695ec54081ea70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4bec02819766e3b82e91e34106055a6137fac578eb813ed4a4c753328a60b292
MD5 b435b9e644b78e3c8ee04bb9a8ea5c58
BLAKE2b-256 5743c92127258b552805029a589e746b70b3c88008f670f693165abadaeefa97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.20.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 854.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.20.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 09fbe30af5dcd336485f55240a5f019cb44d60059e4e5414ad781f5b890b5f1c
MD5 e39753278a631effdc13ce4418507474
BLAKE2b-256 8ea730def6eb60538b0205774bf96ca984878d030fd91533ed8fa17ceb2f234c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf9c3c4dd3b1d17239c8e36bac02104328e7d56f18f27472e54648afdca64373
MD5 ad82538999b56908797da10445712d5e
BLAKE2b-256 79a3a5a931308256d72032560ac8d8f728ceaa53eb8dcc3b64b8c23962dc0a39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cde7637ce036aa60b002217cb5de74465d85359db5714ee290fda963da1188ca
MD5 ea83e1da0393d973216c935ca8083c58
BLAKE2b-256 c05183bf272af5d938ce50dfc4d50ddb117fd9eb16ffd54717099054f16a94d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b32d993d0278cf07c775751a8664b51c31cca5d04ae8e121c1dabf2617da75d
MD5 25526cdf1b2d8bd764816573a2deafc4
BLAKE2b-256 12192382d3d81d856d8701210c2e053078e581c2dae11e03214a72141c475687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 261aad2b33d66fe217bd8236635ca0a433f871ef38ed7e61a239496270421d2e
MD5 742accc4d701b3cb864e5f4de3cf6ebb
BLAKE2b-256 4e7377d2004b2c4e4ec816c828abe0ca766a518ee2da6869b7a86e246dc7f715

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.20.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 854.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.20.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d9bb3a9cbfc49442a83b215562c8f375ca08710022ca8706d439ca8b386568ec
MD5 28392823e174de017ff01c0f8a25e044
BLAKE2b-256 dd3c17490c05c2e2e928842e0d0b0b6b82a14fc376ee5b635ef62d7aca7a63fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ded3c022bd33e9fff542eecbda52a7d4ac2dbc9d7b806b8e64ef5e9846cdb33
MD5 f7fecd17356bb6e10facf25a3cd9feb2
BLAKE2b-256 51dfc61c7a6caf458082642b77a09983a49039141006b8dc4d4163233a560c73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 41d4e4bd2b44b458b139035d1177d3e17c100f4cd1586e00f833744629f27f25
MD5 2cda13f52b5e72b112b65e31998aea49
BLAKE2b-256 f6f04862fa176675fde1aff4f85fb4862dbda7113a231fe3236b82b937ad0316

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b73f44bd04ff68e431fd04a4c5baa7f75d12bd092149f0e512ea74c820eb448d
MD5 e54b8a4a9ef04b3a92b168da81699fe0
BLAKE2b-256 25f7cf2d31af0001e57ebf20e48bf19d361e79b22337aa55302055410d5bf802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 94deca2b52fb91fe30141db6b5355ef85cb854783f4bf5b126be0c34bd5251fb
MD5 96fec17f2a27ff0bbb7451d078acdc67
BLAKE2b-256 be8de692f316a391fdecce2331a6d3eb35ed8d6997f03634f9e0e23f947beba2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.20.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 854.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.20.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 39a654285d796716bf0dbd63c147ea6bcf47c9a649e3c02bf3225bf2c319b141
MD5 0eaf5ab78e8a1851f09c84e9fbc65ea9
BLAKE2b-256 862f5afbb76131b8941984a5602e46551edd298174e7197f84ad83bb17a924e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ef070533ceb5fad7b4de2445ebc8411033ae762efa5c9040a118efb2f17a724
MD5 afcefabda47593a24d9af385e38637b1
BLAKE2b-256 08aba9c437d1bff2b0f660e3e5885de5973a568f1b81168ed5d17632f425e44d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5323364e7a19b3d8a4398ba7836194641c47d8a90ef6903fb399dc32227e4fd3
MD5 39567a49ab94ad128f06b4c2f87a4614
BLAKE2b-256 555cfcb269b8bd9c7fe339dd7ba0d203b817a76a8b490b798a4703be545eb148

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2a4e0ec3fbab3d3e81d833995b9cbdeeb07abd98a080cf459abe95a9140051bb
MD5 1c42e39046a8fc178043c6baa3581013
BLAKE2b-256 d3b3247ff4479e0a71d4b158abfac27911309ba97114b0efdab706f46da7ff2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.20.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 855.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.20.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9e6d931b7a0478692a4729c26d0be1caa7c9251b338ec8bb2fd9fed7f9d8d6a4
MD5 c1f01d68e77ce96d8b6d3c90b649bbc7
BLAKE2b-256 70c2eb70fd808ff5947ffbbdb4b0f11b42e3984a11bfeedde027e883dbc09a52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4544dde7d17fa98676571a26e10e441183e247f6be981c57f786cea9700c37d3
MD5 0531700adde48ec40e89744248e356d5
BLAKE2b-256 f25c4300a838aa6356ffd9a6394b7b8a4dcd6abcfbb3aa41525fc8784f1a2f6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 680ad273ffb5375190a1b27e64b8f0efa213e13b69e25d6c6ad955ce5c44c588
MD5 c376e69a6ac8fa789e9bd7d9d1b481ca
BLAKE2b-256 e1acca3825e8c15cb6224253acaa79f2c4c9d28ac0d30ed0e484e7e986051d62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.20.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4802c9241005a3c0dcb05b2c33378041769d5eb845389aa7d3e24e1a9bfbd5d7
MD5 4298997cbf443c3ea165fa2bb03369b5
BLAKE2b-256 7b6c8d9d7ce8f7db5eae05a6dda260a2a4c92861aeb6f3fbdfd4b2e7cf515f9d

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