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

Uploaded CPython 3.12Windows x86-64

rawpy-0.21.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.21.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.21.0-cp312-cp312-macosx_11_0_arm64.whl (986.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

rawpy-0.21.0-cp311-cp311-win_amd64.whl (854.5 kB view details)

Uploaded CPython 3.11Windows x86-64

rawpy-0.21.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.21.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.21.0-cp311-cp311-macosx_11_0_arm64.whl (989.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

rawpy-0.21.0-cp310-cp310-win_amd64.whl (854.3 kB view details)

Uploaded CPython 3.10Windows x86-64

rawpy-0.21.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.21.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.21.0-cp310-cp310-macosx_11_0_arm64.whl (989.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

rawpy-0.21.0-cp39-cp39-win_amd64.whl (854.2 kB view details)

Uploaded CPython 3.9Windows x86-64

rawpy-0.21.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.21.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.21.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

rawpy-0.21.0-cp38-cp38-win_amd64.whl (856.1 kB view details)

Uploaded CPython 3.8Windows x86-64

rawpy-0.21.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.21.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.21.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.21.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rawpy-0.21.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 851.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.21.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 10c8129a3d9d05f9a92cd3e15894827663148e42ef090a2644f2396f64bbd2eb
MD5 08fe187a2332082ddb6608411cff1466
BLAKE2b-256 7f577a560b6844913e00cfff903d30d3eb51bf19f711130f9361cd874a7e6790

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88c58b94688bba14130a33ecd751b2bc9cd3bdf632f6ee399bba8011e45512d8
MD5 13e6753a3ca0df26cc03c626850319db
BLAKE2b-256 2ffedf5955c63c971292532d123e3742c00f079e399c1716a18b9da4db105366

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 018d9956d897fe26fa5059f5b28da55e4dc87444984f32f84924355feff3af7d
MD5 60255b4b7e8ac493b65958d9f5a1dbab
BLAKE2b-256 40328c47ef730ec6e43ce3f0836fc672c559f712f82b3dd88f484bb8c920c8df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f077a054230d127c3dd9455066516afcff636186c222867ea0cc80ad37cff3c
MD5 19550a39c705b3d5a83cbda5b01cb646
BLAKE2b-256 5dafe2997dcb58779d9730873a589733ba56d7f8340a0be02a39624229652db1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1c71aa37bb8ce75f889c18f7bcf7266f6ad7d39799bbf745539110eff25e64a9
MD5 b87ec74de2807a85d262e9f8e540960d
BLAKE2b-256 c74dd41c62e2501462a9e6ba09c0c1875c6844668327d290a7343d3d5e57b86a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.21.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 854.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.21.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 acc982af3e5d04c265d6e433979d542876e2139edc1ff07c0db358939313e6a8
MD5 7f7fe236d5ec79727e709c93ece906f3
BLAKE2b-256 80168b552d9d822d71edf5e968b122abe6434c76591ee31f3ed33d59f85beb03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0946278700dde363787bb8121ad29d5b7719c9d6ce0e2440bd48e4144ec072c
MD5 b6c95955284284f17a8d2a6b74349829
BLAKE2b-256 21890c93ce128e35ff53839256dc7d1f45add781c1e322afedc64dcae1a495d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b9701ee95a93a2f9f7518cfbe038fce025e80ca0638604955091f71fc6180606
MD5 5c423b28ce3c805feb44e7445fa9befb
BLAKE2b-256 a6a69b398393f4c455ba37ca5cdaedcd94b46b20f8a595a961a9fdf765c07796

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dad77467dabc2cbe356a59580d28cb4244ecdddb4711e64ce879fb8dfdca7a91
MD5 7feede417b8b3d38959d0bf46e267a71
BLAKE2b-256 181da055367800fb9029b26c08d1828f6a53d8b2b369e1b19963d9ab625b646d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8e7d6ce708374e3fc2efc9fd59fbc763679cabe4b31143fe43302374735a1c36
MD5 75b1c37276b9301c9c8126d305b9f660
BLAKE2b-256 3e407f3c4b3fb7d09f64e775c9626c591da6ce89025ca9a348be4b7082a25a19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.21.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 854.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.21.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3b7bed13c847b296bc0c6a27508ad164fe691b105f2e36369c2690109f1908cd
MD5 9748c3d2912b987f5fd0a341c5ee66fb
BLAKE2b-256 e2552925513ede382cbf087539a36418ac832b642db1edd38e2ce2e36100dea8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6915760945ca058b9b1b2184459a862baa33b70e53abeb165d2f3d779eb7a78
MD5 f829c6e871b183a6be8e7cdf64c908d4
BLAKE2b-256 722f80c24a0f24c3a8ae2a9b8cfb579bba0ddcdef9bfd420b98ce69a51b754d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f34efe909835fee45361f7dae1a2792370911ea4b1d19b4aff601bcde2dc628f
MD5 8f107fa07b7e74fe0323555f977e277f
BLAKE2b-256 b1755c0a2878d1af6c295477d084c5fed51d00e92c47f34dcc41840351ce9dd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5a0958ec1f51a2bcccd39fee5daae81fb86e2f3706a839db1e9fcd3ea04529e
MD5 90169de038a4766ac11984c94a94034c
BLAKE2b-256 702c4832043120ef747d5dfb60d0973b76f310ec7dd1686b4861a6397bbcc83e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f33241c8c9d4b42df2c4a8cd3662938e15639f504d14c0ccbfc91b0ae1106d70
MD5 900b52ff82b71df2f503dce23c2dc6b2
BLAKE2b-256 8b3cbd1d2214338656af727e244070b88c1141b08e47aeb99d74e2648f3dc1d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.21.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 854.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.21.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0ee4b0b2ee361de704a69e87b9e49e5b4211ad74b2f4838ac22016a55f0600be
MD5 aeeb40d8a4a46cbe77a093899ee56b47
BLAKE2b-256 6647ec67ac6251d07ce58081a087426653e07759869fb0a811b71df3d16c647f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da8c31df8c78a2ee69352a476133de8239acd5787e24b23f547378a543aeabc5
MD5 8f42360f0de2cafcf1921ef109fa1451
BLAKE2b-256 9b533c4b93cc7aad4abf02e3aa317aabcfb276b40cd4983b5075f9518a01ccc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bdc412d97601943775bae5256406c98d78db61b9657408484864e9cc7c3f793f
MD5 215e9bdc9d4eef7d5cb1c770bb8d297c
BLAKE2b-256 650ed9c03daa139e9e3cf1ffa302b852d3b31f7568e1302af1d7d5609de525a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a5c76b531b35605ab82bf3963e86a97871118979d4ab1464a5cccef246087526
MD5 b3f74f2fa637e44da714d8842ccda9f0
BLAKE2b-256 6f588fdfd4fb5c9fe1a8e54b03a2979872aaa7f69d11f1578a693a8602717137

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rawpy-0.21.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 856.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for rawpy-0.21.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5f7ffcbda108183aedf37618457452c7d0b52799efd2d39b95afba5ddf73616b
MD5 5c8bf239603722d0ceb6be4fe84a4409
BLAKE2b-256 10d5fd18fbdc9f2e6faf812d55ac8eeda2cd8854b8267186921d42ba6b38abb6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b864e3297791b5820432d11a9252a1b47563d90547e98e7cb04385fe754f2b8
MD5 a403291571d5d25314d7197ca96c7fd6
BLAKE2b-256 ce171bee41bf2ac8e5eef9f53dacc80571ad76598d43c5bb006b766bba22ca54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dce0802435f092e75f4f5aee670b4fe4e20f9014954fe274609b5ee4947a4573
MD5 838aad656bd47e683200a247246e0d23
BLAKE2b-256 c214b8c17d16767d5f04be435ebb4e4364df0bed34b37af73d0148cb6fd9d5eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rawpy-0.21.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6de2f293e75d36e178dfcf7bf1578668bc3ee9474f2f004edad3cd1b1af40bca
MD5 b303f66301009ec09a18401b383657e8
BLAKE2b-256 75fdc3dd01edbb212974c8404e2d1b1a3e44e87d25330009dc49763ae21ca7b7

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