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

Uploaded CPython 3.12Windows x86-64

rawpy-0.22.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.22.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.22.0-cp312-cp312-macosx_11_0_arm64.whl (987.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

rawpy-0.22.0-cp311-cp311-win_amd64.whl (854.8 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.22.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.22.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.22.0-cp311-cp311-macosx_11_0_arm64.whl (990.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.22.0-cp310-cp310-win_amd64.whl (854.6 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.22.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.22.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.22.0-cp310-cp310-macosx_11_0_arm64.whl (989.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.22.0-cp39-cp39-win_amd64.whl (854.8 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.22.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.22.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.22.0-cp39-cp39-macosx_11_0_arm64.whl (989.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

rawpy-0.22.0-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.22.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.22.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 851.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for rawpy-0.22.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 440e7694e1ea27ca69506e5003ffd483af36471e97ebfee490159238e2c72906
MD5 6f9cf66bc2632fcb8c9ac47b4b1c777f
BLAKE2b-256 cc8d32f864a38b14e0c0e963cad018bba989fccce3e1b04e23345f6db9aa2fa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5389dd2c3ffbd991cfc931bcfd51a094400513e6343b783a26032193618e8de5
MD5 d04f208fa0f5ede33393536eec96db73
BLAKE2b-256 7fe0e382cc00fa7f0202a1eb9d5eb42ec08a539090d0993862e430504e1741c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7a5a14beabe98e19f51fc0292927e2da81bf98eecb0f5488beecc8d97cec9b5a
MD5 c99bbc267fd8b9dd0c402ef5376398d6
BLAKE2b-256 fcac81fd276f0cbd625a9d6a1c2068dd8508a7553bda6eebcba7b271b2a4234f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b1282726ddf4d9dc3f05c7eca2f8e59a06e334c41ddce8d88fd874e7de545e9
MD5 0e64514ee1cebf2f0dfb2bd87b0d3f6b
BLAKE2b-256 b6457b39ddcf5324f5055a240c462279e68aa428d695b70e34185f222f22e5c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e1a888dd063b63201f54267dbb38ba9575253e31c79faeb8495bf056d43a3f50
MD5 84cf62b22c866a24a9767d0fa79bd269
BLAKE2b-256 e5d263a9973626aafa7eecf913c50338e06737fc80dde5deb932121e5bd34fb9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.22.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 854.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for rawpy-0.22.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5d1fc67256da5fd3a7afd24bdf99125eb77570977c7cd9a3a070b50c5ad75e1f
MD5 9f6775368df635ee2e2d5dc5d7f46ae8
BLAKE2b-256 110ee6855e1dc1ea63b36d014ea592bb048d02a13c89a68ad74bf23cc75d6688

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9463785ca19ae3a643e63d6d6069c23c26cf6f0e3eba67165bce5571ba0d5a9
MD5 e9b4d7a0f0d178f2766650f492dc40f3
BLAKE2b-256 7198cbdb59e45c76b266ceb7cb310376656d6b75debc5292d1b65d4a7d7c8fa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a82f25741ebdef395bc95ec99846e87e3f8e4f39c4b860f57a1744d46c38d129
MD5 ae41c902d8f53629f6dd4f759a74547e
BLAKE2b-256 5f8a785e6dc2dd7df9174e1b676298bbd70163ec47779d13e83fa9d5019b1833

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84eebd1c3e1ca57d6338742b9d617cc718515b484a5ce43060bd8346f5f754b9
MD5 cfc544477e30945539302f16af8f74de
BLAKE2b-256 743417492dac96159936a46d6978326622a270cb9aa3d05e32896e25b7804cac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 80469ba172ccbcc8002a4beaeca5fa5fbf2394c4643b03f52b677217c8710711
MD5 204580ec989ab454b12123411eb834e1
BLAKE2b-256 bc3fde0a94797ccc7456bc6940d4083aa373edf1adf1d4d0f68376259b26a04a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.22.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 854.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for rawpy-0.22.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f1fd988f88c4560d177f09b01e222700aa23d0e05048c86f448da596f95056a1
MD5 fa5bb0b02d3be8088a7c595284356c56
BLAKE2b-256 f772a101a125a81af3f215d7bf659383aa2c7001bb4da5d221d42009c34a1c8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf2f755cac3c6948662e2877a4c57dd3a905c320e106db8b1c8f87a556666dc3
MD5 78c147769c9967c9538b54677b587956
BLAKE2b-256 e9162e0c8bf0128784bf4814f2525631faab9c2fc9b2b0e4a50ce4a65b79ce0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5e369ba1e72829aa95133ab386815d4f3116e9721fc116c8ddce8ae746bb346c
MD5 bb08eb393040468f4a1e90b0aa52ee90
BLAKE2b-256 19500d8438427d0179e8800216f7b0cbaced2d404f5cc8378ce90c933e3d8431

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af1aa3bdbd21b057e67abe8a41f8de911930f6371d7e6b45842ef27ae197243c
MD5 4dbc53bdb2460bdc4fbca7d70a2882b8
BLAKE2b-256 635d7d0f576ae21ddebd042483e254d1fac3bb2e320ad5e08fb43d720aeab002

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9e7cefd4c889e5851ce63e56bfc2d1281deba97929d1fc8b3528f2af0919368d
MD5 169fc121c64660198870986a249fb5d5
BLAKE2b-256 8c62af8548f807a3e243fee400ed56e16f7749028067f5a0f79c0d499f6568ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.22.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 854.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for rawpy-0.22.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fa3f2e663a8adf4e5914aa82ed2fe7f11fe211d0d8d94aa76e3f00063eefd2d2
MD5 5b6c988765be432708e80f65dff15976
BLAKE2b-256 93dfbc76068addbff80f8abd899fb578a1c8f5382adeae6e33c78dda082e1b66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2766509c78ed0ffb4ca8891aacd9616fb17a82ba3713e1a3c90015e489e4c15
MD5 30b47279e6da96f3f991444f42efa5a4
BLAKE2b-256 694964c6a2aacccc974086a544fc38dd4fd9541f42d81cc62a37bc0475eb4d5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 866fb5abda26f36d1ee3750220d80c53d6e1e8adbfea473b74b51439cdabb16b
MD5 36cb59f1da80c85e29676e145ace1e80
BLAKE2b-256 4ad0ae0429fbc85730ef88a15ab82d05770220c3f0802ae4cafad5603699ce02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6205a1a4995219e9c1e36fe828dbd7b3db9d116a0e5ac7523f759ae75671afb1
MD5 ad4b243d53db0ae89b050e09bc3bfcdc
BLAKE2b-256 8556b2406b73ce1654c8201893a162c334f5f9604ec1e240953982e214babe4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.22.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 693097ae970c4a2dcf0a8615c334a789881e0ca4e8be6d3e5d264da5a6888ce0
MD5 6c9f0b48d99428a5fc3679c2bdaf4855
BLAKE2b-256 87202f8abb42862a8b960e427d59a5f8a062e0803e37a921d99b2e0b6d2fc642

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