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

Uploaded CPython 3.12Windows x86-64

rawpy-0.19.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.19.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.19.0-cp312-cp312-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

rawpy-0.19.0-cp311-cp311-win_amd64.whl (853.9 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.19.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.19.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.19.0-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.19.0-cp310-cp310-win_amd64.whl (853.7 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.19.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.19.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.19.0-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.19.0-cp39-cp39-win_amd64.whl (853.7 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.19.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.19.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.19.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

rawpy-0.19.0-cp38-cp38-win_amd64.whl (855.5 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.19.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.19.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.19.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.19.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.19.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 850.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for rawpy-0.19.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 285ef8f89b59826344513c01d66e7e1e7d07e968e21a41908eec5593368fc88a
MD5 4e87c44d9a8a6c8309cfb622825a9da9
BLAKE2b-256 5cf30733c25cbd28c2595fdcb111fdd96b9393093e942c4dd4d58364fa9ff346

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be0e4e49ebdbb6d4d1f6ec7b93406b4da53372123f0ee13ec1682bdcf20b238f
MD5 27ea15995bc5beed24f47ae8eafdcab0
BLAKE2b-256 3002060de81ec1c1a6c65cdebd46fde26a8891f4f54f46ba8d5fd37fc605879c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fe6b7fc7d1d53ed06962a46aa723b09d593bbf70d23c5cb4b1a6a3fb64276cd6
MD5 e8cc9d2a1c10719539526ee16f27c14b
BLAKE2b-256 8fcf75aaaafb1fc35712955f6dc8bc44790d6e1f6d4d7db3f890bf80c2b85cca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 064e657c478b330a4460c5b58f5565dea6b2003013e036ca3058386bc3521fe1
MD5 66cd79ffd7963d461b482b170d21d515
BLAKE2b-256 4fd2b5c5cc1d55f97e73ce14fc90089de60e771de7a06bcefab66be428002784

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.19.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 80cb145a8710fdeded60a79bcdf8224c8349c26e7addb7253604dbb36e3bc0b0
MD5 09a87a44cdb5a12fcd6974766cb5c381
BLAKE2b-256 1296f01b045af5f19dc01934d7aec80260cdec26b394b75103ee3e1f503e9957

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f6bfc5b9126de96b1f67cda7d39bbb28a9af1ed8b91c5a1fd9417f4d6327749
MD5 71b95f397d6116532d445986812bb035
BLAKE2b-256 be162d5fcb11fbe265b015010567352d99248b5a57ef22cae2919bad249b0e08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fa3e5b275c49f77d4ba9d177851e5d499ad34389b509b9f64b4fec2ffcece337
MD5 eb1d212a04f89b3d55cd2e9e0a177318
BLAKE2b-256 3529569ac614111f882e43c98ef801fb8b95db5ee84a4fa8840178e2c4f77fc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e575d5bfa0168bbded845bde921dcde03bb7ffc66190a902fbf6b8a7473e87a1
MD5 deac643477c8e3523f080423a22a124f
BLAKE2b-256 28ecdb07f6b92fdc768a7537e54c258f0328e3bdec3b3a0d8d03412fb706ea7d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.19.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ece54693d92416d91b149e6ee50f479dd0be81858ac78e7c5e1047e19115c328
MD5 7e6e91ad3cb87decd38e143c030f1332
BLAKE2b-256 c8a1da74b984334193c3bbb19af395817359587cf89a68534117810e0f860f28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5eee1379200325171f976518918930357722d21b4241476c8537ac6884ed3f16
MD5 17a75e67da6b19f7f681b3555b0f008e
BLAKE2b-256 355862caf571fba343c93924e3d301210630df49b4751f77491a9da54ebdf0c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c094ca1a0b892e6b9fb8f8bf177a92d94af4218dee8ee6496488a309b7015dd6
MD5 9496c014c065f596441e4cee0df8bf90
BLAKE2b-256 7401635709c04b22a17c57b06aee99292027ad248045bdb4629da1e7b755b6ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 663766ad644e771491c31b597671cf4780da8449289492fd4cfc3689aefe47dc
MD5 ca53d7535319e3e512e7ade3aa42596e
BLAKE2b-256 abc5840840a74520be346105b0d4b16681ed7b69e5dfdc8cebb93ece116afa11

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.19.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5ca0ecf879de387f5c47d8d7308a0afaa259e63ff18c032637255879083a0102
MD5 576dec306a266fea806452f1c181d9b6
BLAKE2b-256 5cc9d0df63a062a3f8917368ed13b04232c7db6c223e7755a3d198747ff236fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4120e8f22dd147abba331fc14f51ea20b62758dee46b76f893c59afeb636c7cd
MD5 a85d4195f2623a9f575921761e0ab175
BLAKE2b-256 40ae8d0e3f03fa5b2b145471744833406b864f5336e647a3921d8b50e5717e43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f9da7fec99d2403f01ab3dc13b510313cb42eb76e0f1307d861bdf165fd1c467
MD5 dbe16bc12b942b8976e1dfd18ab71b9b
BLAKE2b-256 2dc4a97ead715ff449e75b64f9ea2034af3b1971c2f56583c23f034e953f6548

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bd562fc1882405eca01515642caab773dfec5e54cd4c10fe3f4ef39d8526aea8
MD5 32d494dfd4e61a1509c1a75003cf31ca
BLAKE2b-256 6d5e66aa99818d23ad8a215d04170d14a701432d6daa1162bc3ebba9c37db9c5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rawpy-0.19.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e53b6f2a85fa6c2bea64ea0c82242b6d62b725f837d30825869f877ffbe3323c
MD5 0680f14d3e57ee8b2f674fff04f0c1a0
BLAKE2b-256 a1fcf1cb1d209c19c2cac1b3b7af0266a28dfd8899ff763fd676695ed75ed145

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21bb29104425fbaeb7269acf33ca5dd286f7fc913515c4abe4c4ff004ed860be
MD5 20c4e8575f9046a4e181b93f52ce87d9
BLAKE2b-256 26a04195819fa22b44a1008c5f1c93c0ee60bec9aa6040950ec315c946373168

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b0c6a829ef472f0c8684ed2d650aedab4c8a8713da54bfa94e479a5e483b3ae4
MD5 a80b4957c5c2e98e35acd67e6d40be4b
BLAKE2b-256 18f1533227a27118b8e482b0de50b5150cf4cd40fc99550ed084db2fb320980b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 696612059fab1c1f5b62605aa217248bfd1639906f665f6b9e7e17b78f67d119
MD5 be4ac632c20c90fc01283fa1e9a49ba8
BLAKE2b-256 826777630b401f89c47c026d5788e2c644c4176c9f5cbcbdf84d6c08bf57c81c

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