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
3.11 >= 1.23

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.1-cp311-cp311-win_amd64.whl (791.1 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.18.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.18.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.18.1-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.18.1-cp310-cp310-win_amd64.whl (791.8 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.18.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.18.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.18.1-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.18.1-cp39-cp39-win_amd64.whl (793.6 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.18.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.18.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.18.1-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

rawpy-0.18.1-cp38-cp38-win_amd64.whl (794.4 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.18.1-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.1-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.1-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

rawpy-0.18.1-cp37-cp37m-win_amd64.whl (791.6 kB view details)

Uploaded CPython 3.7mWindows x86-64

rawpy-0.18.1-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.1-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.1-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.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.18.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 791.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rawpy-0.18.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fff49c7529f3c06aff2daa9d61a092a0f13ca30fdf722b6d12ca5cff9e21180a
MD5 129c5ac60560e3e441082399f2fc8f2f
BLAKE2b-256 691b86d59f5966dde478a19a0502967d141c6f34cb813fc5e5f7b38c30369eb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6fac80b3aa1cec375345c14a63c1c0360520ef34b7f1150478cf453e43585c1c
MD5 7796eced3df74921b47ba9ac579cdc64
BLAKE2b-256 924f62a5212d944c59e54ac6ad40d25bf6c6de3827cff6ffb088cab89e9e25c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f3b352da1316f5ac9a41e418f6247587420ff9966441b95f2aa6cefdb167c51
MD5 d23d207d52a30487ccb59f371def2ef5
BLAKE2b-256 4b5df3d6b5988c84c40fde14b1021d3b77c5bdc8cd46240309b69dc7872534bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e836ff1a0f7d8eb24665f4f230a41f14eda66a86445b372b906c2cf8651a5d17
MD5 a56668670a67223a132aefd09a5bfbb7
BLAKE2b-256 c6bd337246b7877450002c6b3484a434f9884a890b240a42cb381c17ed69c65f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.18.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 791.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rawpy-0.18.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bc2fc6e346278ea3fc0fe76b704984551055914905e6187be7844fecfc756b22
MD5 e1ba6e77d35cd330c43ce998b369f262
BLAKE2b-256 e0ffc02a884f5c794a6fbb1a0cfac166f95dd1f3da984dfbdfa6428c8dffa60a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c0a040c33fe3b14a6bd9d81a8c2d6cb49657530ede982ca1585108229fec651
MD5 948c052b93513965fbce0c5df927e64d
BLAKE2b-256 b7633bfe118b3981dd1b13c399ebb90342b8412330b4c206cbb2f16066653c7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c6cdb86817f4740c3252d4797e0b5926d499330b46da1255d56d6a401a34c3ec
MD5 636fe37da11d67dd3d7d0114fa3983bf
BLAKE2b-256 6eb35e643f07a2ab11f170ac049c406e71bd3a54cec4b23861bd49928089fbb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 30f5a7f3b80db8aa18876831b73b5cf0530da3f2dd8be9870cc1bae271b5fdb0
MD5 37637b177bffc2810f10cd6089d3a59d
BLAKE2b-256 aa09d2af73aaadba85a3e3e1c889adbb6b8bd06f3a9970c1796b81699eaa9855

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.18.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 793.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rawpy-0.18.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 139715d16ff64c47f53972e6b07576ce5c47cef899a187b149750855d08ef557
MD5 9130c67aae0dff073ec3a65529e2b4e9
BLAKE2b-256 ed06f24fe39e77bd4d7090a35cf5406abc8fecbb315315ea2686d752ac9e64bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1a6437ebdac9c3ce09932d752eac7acfda6e56a7996b211ac2a625b80168dad
MD5 d8cb296c66bd0bef6c4db81a6e18b06d
BLAKE2b-256 7454e555e61753dc89c33be1382f922f6978f64c3595a70792e4a67e959774f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 10cea749fc9d8cf1ae716172dd09b36accfd1de576351ce6a650b5b30f9dc6f8
MD5 2b4e31b70274fb70b19fbc4c8ce82937
BLAKE2b-256 d15075a85a1e3d7ffff4f27358483c4333410086520447279f24561c76675225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 be306f686039dc2e2f7374ba15ce64b4392f10ca586f6ca6dd3252777588e750
MD5 1f709d531bdca8962cb19ef2f5a2adec
BLAKE2b-256 9efb42e35b83b2ded8f56dd484515aa9ac77f948e589864b45321d93500d5cde

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.18.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 794.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rawpy-0.18.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d37c144ac4922ce20acccf93bb97b2d5a3e06ab782de58d9630bd77733962cb6
MD5 60cdf093f1d701219ef775fca05fde8b
BLAKE2b-256 63f9990b9c79b36e1b7e452afa66877a303c5dccf49351a84cfd073f52ba7f80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfd92c94eae2f8bdde4b249007f8207e74f0bc8f3f5998e6784eaf1e9b67dd7a
MD5 277f42d53e8fa77597d7934802288333
BLAKE2b-256 937a0d45baed896e1a827079b841451265250d1b8de0edddfd707b17f1f80cb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 18171458cff40f968797fac4681aed6ec9bf3b2278b2235d39b09f987d2470b8
MD5 0330c0eceb1b53f5d19024b9e6075fc4
BLAKE2b-256 7ba30a40245392c7c4b9634e12764334ce7dd0401b873e8f4d778fb5a9927c27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 710fdaf4af31171d847eae4dc4bbd717a951d75d159cdcc27a9ee8b046354447
MD5 0bed7697418a7d0d609f65d04db0098a
BLAKE2b-256 c082257c93ea691a1126af89cfec51d01ff0e4e221a89179af898b13802f4c14

See more details on using hashes here.

File details

Details for the file rawpy-0.18.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.18.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 791.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rawpy-0.18.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a4f4f51d55e073394340cb52f5fcb4bb2d1c596884666ee85e61c15b9c2eef59
MD5 d9a00826d1d629104fc1ff9e8f4a3c29
BLAKE2b-256 a4b5809b637bcba8feaf4ca3ef90a605172e0f0c1c59e2dd1103a0c1d80d6a8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6effc4a49f64acaa01e35ec42b7c29f2e7453b8f010dbcf4aacd0f1394c186c
MD5 2ddeaf0ae061a83fbfab4d3c1c06f007
BLAKE2b-256 b2f37be7fb3c12eb3dd559a791a5c4797a215e247e4a4e6abffecc5e509cd7fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.18.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 08160b50b4b63a9150334c79a30c2c24c69824386c3a92fa2d8c66a2a29680f6
MD5 ae54f45881198f3ce6b212151abdca66
BLAKE2b-256 a4d1331ca9bc006cdc54b923ca761b54feeb088ca48d7bdb2225ec7f12deeb10

See more details on using hashes here.

File details

Details for the file rawpy-0.18.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for rawpy-0.18.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 296bb1bcc397de4a9e018cb4136c395f7c49547eae9e3de1b5e785db2b23657a
MD5 e0c7e02f4bb101407193eb76b395427d
BLAKE2b-256 a5431799546599fa7b96d943c591edc37982818072b7ddd7d9e0566b8119bcf9

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