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

Uploaded CPython 3.12Windows x86-64

rawpy-0.19.1-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.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (986.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

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

Uploaded CPython 3.11Windows x86-64

rawpy-0.19.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.19.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.19.1-cp311-cp311-macosx_11_0_arm64.whl (989.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

rawpy-0.19.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.19.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.19.1-cp310-cp310-macosx_11_0_arm64.whl (988.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9macOS 10.9+ x86-64

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

Uploaded CPython 3.8Windows x86-64

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

File metadata

  • Download URL: rawpy-0.19.1-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/5.0.0 CPython/3.12.2

File hashes

Hashes for rawpy-0.19.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7dd2aa43a1fb10ceca1dce8a1cf059ce7687ce7b2b805445092b19caebbf031b
MD5 9b97ba9112295b51e4f0148b05f27a2f
BLAKE2b-256 6ac72e94ec08351f0bef1f9e51787221436c57a3c88c16c81e9292176ca177f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 978dc058026f255d13d978b6cd2bd5ce621d95e3ffea92507cc6348f0616fb1e
MD5 43c740e10425c16b5f53642d3690cae1
BLAKE2b-256 d700e2bae0cb89985136f824c2a86195f52dd8056aedc5f5ad982e1e62cc7612

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e3e32c1b51822be0017d463696fc7b4c58e166ee83c51825e015ce56bd82847a
MD5 4e79a2e68b262f9d75ed7446958a78ae
BLAKE2b-256 f83d54e74dc38dde9f250d9a89ec5b8d27f70e40a874446d84e6e1adbdb2d188

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c160bdfcc7fa0a133b3770bf8890d90228c2c89d624d23ad8cd3793aaae556ec
MD5 381e904e9cad919b5eb071c881095007
BLAKE2b-256 50722e16e225e47097f44bb361339e0c50c1dfbf4ccce3117781b78a6b1078fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3f49c630e3c92d7f682f0150c9ebf3ea05c3673da72750cb3dcc06bd6b39d961
MD5 8cbffe2f9c1f50726be125c6bec4471d
BLAKE2b-256 f98603596ab27747eb1dd2fa879b0090ff49d19afd29d9916d6416b8bbde40fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.19.1-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/5.0.0 CPython/3.12.2

File hashes

Hashes for rawpy-0.19.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9ac48089ce41ed1cc397a062341c7618106e2815350e98454a366e3af1b05dfb
MD5 b68a062b0ea129b887d5617426aa8f7d
BLAKE2b-256 46754fd497420aa0cf1f3f8f98b752cc115155940383d3f75fa9d5071247f9ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 505eb62a3d3d13b34b4ea2d466a5365b1ff59d50736b9e29cc97bd14aed7c170
MD5 e897a19325e64248509832f3a4e96020
BLAKE2b-256 0f12353e64cdfcb582713ffda7dbd72c2f9680e7dba39d14340ecaea2ed28a7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e9a0455b5037287177ec991283969bff4a9ac12599105b8335ef3e74e7fd2a88
MD5 2fe27af62b51d0a073114c54b9fd6e6e
BLAKE2b-256 2543e4c48dff8e0afbf716e2fecd80455bd53254cef8acf051c9fd5e12602644

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a58b353634da07a7f6cf4ae8abd7099bedb0624a873031cf129d52706c06c83
MD5 c5b497ab892e4f2d0ecd5ba3fcdaeecc
BLAKE2b-256 96f5cde4b42a05aa10a4304be36ca92b13798a9120b70a40d73710d17391f71e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fe5529e778ce0d9539c2c24df17d52687317c9edd03c9586d732f8dcc648628f
MD5 cb4686a442ddce9bd89e85a71166a426
BLAKE2b-256 fef02631a97170b5769396d9012b6743e5e16bc2b4f9839c2c88a345eaff8d19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.19.1-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/5.0.0 CPython/3.12.2

File hashes

Hashes for rawpy-0.19.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5feeeb69630b0f10f8bce21bd359590de33b524e6c490b3a3919e2f70124ee99
MD5 ef6aa2add7b8e9232b93ef31c84cdf97
BLAKE2b-256 5040ca874199e16817537cac7e29a789869dc5cb9098829f73066b01606b0bab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a7052223bd0c2e0624b066ee56013da1a2f5df2f2e01020323d33937450f8f5
MD5 7bfb47ddc0e2e34b018906b43e326ee2
BLAKE2b-256 402fdf7e7c49e824d0bb37a135d92f96ca776bbe00d80336850d418862599975

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4486f36353b4e34f8abae99f580de4652576f03caf6f8b8723d49547c63c7902
MD5 61e64e2bc942c7de221e5b554377bb95
BLAKE2b-256 616ef6ef1316df8e9ed9c519ce2e8ad42f2cbd9217c7effb760628f7af256888

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b1868e500de5b85d80ac716689eb559a601553f4df11b4891a5a0eaeac8c34e
MD5 42119ea9f2ce3dcf232ef84d4de1bd38
BLAKE2b-256 b49f591141513be8cbd6d2890496ea7dcf6dc1861a1d93978070f8c8e4a449e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 59011f447f7d71b5d85c2c9394642c9bb671b70bffd5cd0c030232792ac4204e
MD5 3f6c1a15edbd7653c79d4c96f0745913
BLAKE2b-256 a0ac89f8c1722ac19b6cf66d802847fbcbc27e8c0bfbf38525428f70ebedf15b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.19.1-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/5.0.0 CPython/3.12.2

File hashes

Hashes for rawpy-0.19.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c222a6aa0f4de5e4beae0fe99405af2ec080904c73fe2705fc9eebf4971fe52b
MD5 b6014e4845f910a75194ce4d79d85fce
BLAKE2b-256 d6a09a3ca86d9ab70660b4a8a134d827ab9fde9c917b3fdb8bf4773d208d5a4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 42934401cce5bd5d8e1bd0963f18045d33016cb25ba7ce2d006c86f4281921f5
MD5 fa99f0a5e6d3980fece7dc68dcb3e7cd
BLAKE2b-256 4e2b102c6da8fd9c22af28c798032bb94f910b4b44c33c24ad8c49775b16de3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 32d14d0e1f36d47a5cf68e239bcae85c905e6d742b072ede477ca14c398e0a77
MD5 3c968e36360ea57a77e9d982f7c0f23b
BLAKE2b-256 809b0638cd67b50b6255ba403e3bc05e5897d27ee97e0f94688acb19f8fb8173

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7fa4c2000d62978349575d13d75f27acae050339eb21bf9c4a0525fd0c62d007
MD5 e4d22c2ad14193ea8be96110258077b0
BLAKE2b-256 9489d70e7bf938f8157a6b86c300eac5dd0fcf1adc35e069cac0dff1cfcd0c50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.19.1-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/5.0.0 CPython/3.12.2

File hashes

Hashes for rawpy-0.19.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 8e7d207eedaebd33e6bb7d9febaf03bdcb30b477a8f66ad58ca123e395ca707f
MD5 47780c9b46102828423c23b4b622dbeb
BLAKE2b-256 20d461f5acef4a5e7ce80a5acfcda023761fac52c1d911e8fdbe303231458b93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 562b918a87fca306b2161ee6e5a525a1d8e3daa8b882b10366a849835c09a3c1
MD5 d88433a03f84c131e9913471b6939b7c
BLAKE2b-256 86638fe097b7f87f81f2340a48c295f01203b299dc0674ca1ecde6e0a87a6216

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 82506b3dc78ab1e7c8e81fa5d57cc9512e325b8b4b40cd1e9d1849af59bf8ae8
MD5 c3f749aab3b9144271797276f95598ac
BLAKE2b-256 eb84b6a3086a09d47018089ea51fdb6bd63f6fcafe1a35257165b4efe678977c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.19.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8942c6f7f68d9533c38e1f224f9abe3ff4eb480d56281c329f4acb980db6e38b
MD5 bef00721d33443ca6b978d67622cbb72
BLAKE2b-256 af0f6322b4ae88c08472959fb28ec2de3bf5afa4de1e5f969103969264f34720

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