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.
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)
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
Binary wheels for Linux, macOS, and Windows are provided for Python 3.5, 3.6, and 3.7. These can be installed with a simple pip install rawpy. Currently, Linux and macOS wheels are only available as 64 bit versions.
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 |
no |
yes |
yes |
RedCine codec |
no |
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 Windows features: The LCMS color engine and RedCine codec features are currently not supported as the automated build process to generate wheels relies on Anaconda to supply any needed library dependencies. For RedCine codec support, the Windows variant of the Jasper library is missing, and for LCMS color engine support, the LCMS library is missing.
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
If you have the need to use a specific libraw version or you can’t use the provided binary wheels then follow the steps in this section to build rawpy from source.
First, 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.19.2
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 .
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.
NumPy Dependency
rawpy depends on NumPy. The minimum supported NumPy version depends on your Python version:
Python |
NumPy |
3.5 |
>= 1.9 |
3.6 |
>= 1.11 |
3.7 |
>= 1.14 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for rawpy-0.14.0a1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2927d6b00df9db2a0f224ad4190803a84079285c10b08421e0c57e6c48597d7d |
|
MD5 | e8906d145f1a1cf2c8dccb0dd504e632 |
|
BLAKE2b-256 | 8d070715e419ff061ec0b217d1bb51eef44d70c3edb882935f6d912afb4d147e |
Hashes for rawpy-0.14.0a1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5b642a6e0c09cb19470b7ee62b10c8aa57bac74f06cce61fc61b902754e46b5 |
|
MD5 | 8d9b1d5b11b9914aad124f36b350aff8 |
|
BLAKE2b-256 | 2de379829dc15a90d37e55b70bf8a8d14bb182912fd274d0cb8328d6f669397e |
Hashes for rawpy-0.14.0a1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 060aff03e65015477d78af3ea4980d313a5b7f1733256159dd3720ff5e493a93 |
|
MD5 | e938810bed4d242ed4a8c57f81efda20 |
|
BLAKE2b-256 | 05ec96cc32c177f82c8a3363f9f419b2505cdc49ff679884d413b4c5a933340d |
Hashes for rawpy-0.14.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41dd9bee62c23c3b689948023f859fa5d95c0509747b979af352c8d0ebc99e1c |
|
MD5 | 10b26f284801dc1fb7f004810dc9cb62 |
|
BLAKE2b-256 | 372d877837ba565ef4e608de9521011111765d820697b7ca13f25c15d7652b23 |
Hashes for rawpy-0.14.0a1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00e742805c64fde66155eccfd61c6fabdd858b67d4c7a6e96f062ace186e7fd4 |
|
MD5 | 21bb02aaa7d549343a6de961a902d505 |
|
BLAKE2b-256 | 16c218179f638062e9a9b4c744a974bb44192fa0537cd6e192bf55352d4a6fdd |
Hashes for rawpy-0.14.0a1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab7391f149042718ed02b572d7e1f131b445e4dacea59c4f51f6a90cb8228324 |
|
MD5 | cb3ba546273df5239e2cef589262887d |
|
BLAKE2b-256 | 14f71d85486a6636ebd905075bb60a05b1c924a7c1afb11b22d9a8ab59fd9339 |
Hashes for rawpy-0.14.0a1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eab82eeefb2e8440d07faae47ff50c3ce95b4fe082d7cb1660b4bb6637aac04 |
|
MD5 | 11aaafa414d1d17b3e6f537d0ea52979 |
|
BLAKE2b-256 | b8df7083f65a55b06a752ce989d5726edb9b2a6b411c0ad48fc519cb7579b17e |
Hashes for rawpy-0.14.0a1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9adda3a206080b3fd80f19ebb605fef76c0cdcf975a2416735ce9b8d4767e209 |
|
MD5 | 6ec9561ea2df40fbdd4eb132595cd635 |
|
BLAKE2b-256 | eb34eff3762ec855f17eca4c67146c088b81e126b78c9e714835d65113b3ac8e |
Hashes for rawpy-0.14.0a1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2f10dd6dc4b3dc5751a60329bea70fb21b426fe9ddfd8adf63701d523d79e8d |
|
MD5 | 60362818f5a1dd9b2e46de5d897fdbb2 |
|
BLAKE2b-256 | af01f812eb334675a9b3bb75079c93d898668aa05fe759fb4e99c8b7e12a28a8 |
Hashes for rawpy-0.14.0a1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ac1dfc79b484a1be714451aa7e5d257ff293e80424415a578d15e444f8523fb |
|
MD5 | 1c9af3968b00ed3a7ecb544204b28409 |
|
BLAKE2b-256 | 0ab8bdb6adc61a07bf2317cd55546fde04f7e44589eb7dca5ab9acaef3b5abc7 |
Hashes for rawpy-0.14.0a1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 685fcb4f641ae7a60df830645f9e8393c378cc6fe483296665a75cbbf4db8e56 |
|
MD5 | 4a1bbb3a1dc0b6637577e8ccd6a9d2b7 |
|
BLAKE2b-256 | dcc4ec9cb733b112ccda792801efcce6727305efa4e83e80259e6c2d6b5dc826 |
Hashes for rawpy-0.14.0a1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c3e84fae496430a3cc150d1b5cee14f0719dc9375148231ebb091332cc0a91b |
|
MD5 | a8e88ce366663a39cdc7e648c6794248 |
|
BLAKE2b-256 | 9cc91a6d8ca8c698a15c803d15106acaa57f070a8275c506a7bda048b17c09d5 |