All Projects → letmaik → Rawpy

letmaik / Rawpy

Licence: other
📷 RAW image processing for Python, a wrapper for libraw

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Rawpy

Optimize Images
A command-line interface (CLI) utility written in pure Python to help you reduce the file size of images.
Stars: ✭ 141 (-44.92%)
Mutual labels:  image-processing, image-optimization
Imagemin Module
Automatically optimize (compress) all images used in Nuxt.js
Stars: ✭ 37 (-85.55%)
Mutual labels:  image-processing, image-optimization
Imager
Automated image compression for efficiently distributing images on the web.
Stars: ✭ 266 (+3.91%)
Mutual labels:  image-processing, image-optimization
Gyroflow
Video stabilization using gyro data from GoPro or external logs
Stars: ✭ 204 (-20.31%)
Mutual labels:  camera-calibration, image-processing
Boofcv
Fast computer vision library for SFM, calibration, fiducials, tracking, image processing, and more.
Stars: ✭ 706 (+175.78%)
Mutual labels:  camera-calibration, image-processing
Essential Image Optimization
Essential Image Optimization - an eBook
Stars: ✭ 1,950 (+661.72%)
Mutual labels:  image-processing, image-optimization
Imgp
📸 High-performance cli batch image resizer and rotator
Stars: ✭ 744 (+190.63%)
Mutual labels:  image-processing, image-optimization
Nuxt Imagemin
Nuxt module to minify your images. Works with: png, jpeg, gif, and svg
Stars: ✭ 170 (-33.59%)
Mutual labels:  image-processing, image-optimization
Imageprocessing
MicaSense RedEdge and Altum image processing tutorials
Stars: ✭ 139 (-45.7%)
Mutual labels:  camera-calibration, image-processing
Computer Vision Guide
📖 This guide is to help you understand the basics of the computerized image and develop computer vision projects with OpenCV. Includes Python, Java, JavaScript, C# and C++ examples.
Stars: ✭ 244 (-4.69%)
Mutual labels:  camera-calibration, image-processing
AdvancedLaneLines
Lane identification system for camera based systems.
Stars: ✭ 61 (-76.17%)
Mutual labels:  camera-calibration
docker-imgproxy
🌐 An ultra fast, production-grade on-the-fly image processing web server. Designed for high throughput with Nginx caching. Powered by imgproxy.
Stars: ✭ 45 (-82.42%)
Mutual labels:  image-optimization
web-generator
👑 Gulp based task runner which creates HTML output from Pug HTML templates
Stars: ✭ 13 (-94.92%)
Mutual labels:  image-optimization
Menyoki
Screen{shot,cast} and perform ImageOps on the command line 🌱 🏞️
Stars: ✭ 255 (-0.39%)
Mutual labels:  image-processing
imagekit-python
ImageKit.io Python SDK
Stars: ✭ 27 (-89.45%)
Mutual labels:  image-optimization
CalibrationWizard
[ICCV'19] Calibration Wizard: A Guidance System for Camera Calibration Based on Modelling Geometric and Corner Uncertainty
Stars: ✭ 80 (-68.75%)
Mutual labels:  camera-calibration
create-optimize-images
♻️ Reusable, scalable, bash scripts to create and optimize images.
Stars: ✭ 39 (-84.77%)
Mutual labels:  image-optimization
imagekit-javascript
Javascript SDK for using ImageKit.io
Stars: ✭ 43 (-83.2%)
Mutual labels:  image-optimization
gulp-kraken
Gulp plugin to optimize all your images with the powerful Kraken.io API
Stars: ✭ 19 (-92.58%)
Mutual labels:  image-optimization
Ai Job Notes
AI算法岗求职攻略(涵盖准备攻略、刷题指南、内推和AI公司清单等资料)
Stars: ✭ 3,191 (+1146.48%)
Mutual labels:  image-processing

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

Binary wheels are provided for Linux, macOS, and Windows. Currently, Linux and macOS wheels are only available as 64 bit versions.

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 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

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: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 three environment variables.

NumPy Dependency

rawpy depends on NumPy. The minimum supported NumPy version depends on your Python version:

Python NumPy
3.6 >= 1.11
3.7 >= 1.14
3.8 >= 1.17
3.9 >= 1.19
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].