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

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.0a1-cp310-cp310-win_amd64.whl (789.7 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.18.0a1-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.0a1-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.0a1-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

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

Uploaded CPython 3.9Windows x86-64

rawpy-0.18.0a1-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.0a1-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.0a1-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

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

Uploaded CPython 3.8Windows x86-64

rawpy-0.18.0a1-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.0a1-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.0a1-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

rawpy-0.18.0a1-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.0a1-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.0a1-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.0a1-cp310-cp310-win_amd64.whl.

File metadata

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

File hashes

Hashes for rawpy-0.18.0a1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4b612fc41e334ed1f2499c7c903354eb6230e4bca756b37bb893238847374e16
MD5 3b52ae0949543cb47ee00f008d2c1667
BLAKE2b-256 38177a9654d6ea8ca957dafa31ed296347b96a12157654bfd8376892d21f0624

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 292e9c251e349ec8680e28461f6de01ab88fbea3fb9e3b95f996cbabbaf91daf
MD5 ded94f93e70d4aa1ee59b0a4e9b707b9
BLAKE2b-256 15f3d8670812142df5f513c8fb1f402e14187d6227e72e367eed76668f394e2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e9893df91ab69f023fe8676b0ca898db7088e29ad5c81e013152163362d65594
MD5 9efc8b6b68928a83e770066d1b7cb3fa
BLAKE2b-256 a88e7e424ae5614729da3a34f629b868375031ab4ead1162481574d81397dc78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 97ecead083e14549e4ce1c43c4ecc7435cc4e418892cfadec93faa17bdae6634
MD5 2411ef9adc2841a1e85db1619f7019be
BLAKE2b-256 7025e834b7105745427e57a1f1b904021658d222702f2d585f702f8f43230068

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.18.0a1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 95716969151ff2c1413418f8f91697f3467f7e447769522da4a5a7bf618760b2
MD5 d3aef02d76ac429cb8d64e7bdd0f4b62
BLAKE2b-256 1064aef98bc9f610afb37841697d3662d2cd5dc2f1204557dc02833baee8acd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80337d98b5f0ff0c005128c016381b74da6a11476743c11ae867d711e5d75534
MD5 02a3e9481db8e3b9aab05ab0236942de
BLAKE2b-256 27431425d55996f9d1873aa57b104bf2d6f27cf68070040a59a64a732854f197

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 50c4a9c1d4320be044372c343d7b322a781b5fafcc6b2e0977990797e2131b17
MD5 7be4bccb4a517f95ca772e447d285826
BLAKE2b-256 7c5c1bb9b323ebdc8ce3c025d8eb73bd476790ac64e816f258e40289bfa296c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2be926c962113849a9f0a6b5566561adddf6292c92a57e059873c8be341d2bfc
MD5 bc8f1360f07c74d4ecb32e243ac663b0
BLAKE2b-256 1cc72675591caa3c94f1e4181bae917720822b10886470069f00d85946d38609

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.18.0a1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fb21790ed0242066073123e1454f2306a3b53a754dccf540f17c2c91f8cc32f8
MD5 ba379216589078dad4ecdfdc64edf7ae
BLAKE2b-256 c499fc17db453b0870e36580acf5c523512bf0e33c1e63be3eb0a4e7eba8cb3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e12cf65b1f99a4d8d1985a44b06e0e37511db11883c7edd90b69a5473072c72
MD5 77133d376727b1676a53c6e7e9f5ed9a
BLAKE2b-256 777997951f49c44a794320327940230c22264d48c70fba4148f926b770bfe1dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4dde1cfabd7e9d01ab50f68525a5762277fe995927cc1816849578058feb874a
MD5 ecf06ca0f393d077bd396704bbe015e8
BLAKE2b-256 36c6d06234236982b929bcbf8ff94abf1c95e02ffe91d3faab1972c7b2fb1e2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bf6a4f445e267c1896a0e8f83b4cd02b11743567472ca0253766fa2ba5853401
MD5 3e25d9c9ab2e1fe5109ea5102084ffd6
BLAKE2b-256 8522c5247203999fe0b431529a7d82bfad3249a182e1151b99e5e319ba99525b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.18.0a1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ec85e6a3c7d3fa056ec5b450940da12308b5d3be2c2d94d2fc14079637106c89
MD5 282a7a989b3e3c5916f4cea7cf857f9e
BLAKE2b-256 3b065b24aa3efe8489c257af45560aa533ffff16cdc9950b3afbd615be50927b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52fbc5a3e2e180072d638b79ce5d62d8a1b669e1cd245ec11b471c2a91bc2ec3
MD5 8e6c37818697c656bc03905529f94495
BLAKE2b-256 e8df2f6d4268f6aafd114c5e5c34790b01f3d52c429075967668aa7dce3d8903

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2bc0a27a2e1852c7cf0e8cbbac3ad55eeb5b762249312563b966a662861396dd
MD5 e01ec81c37590cade85e06e5c217bfe7
BLAKE2b-256 69492ab8bb4501bf6bd53fd94ca4279edf352fb9161a316cfed2ef0aeaa2f717

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 80c694e7f1ce121e97cf1ed535a150ec2de300150cce3d4e3ca08c1ffb408be3
MD5 cb96693e2a35f81760a7ac83eb72245b
BLAKE2b-256 c9bab1232d1395007f22dd5b0b85b61f499411ea3e0e03a6c77c14b7062ac227

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