Crates.io | libraw |
lib.rs | libraw |
version | 0.1.1 |
source | src |
created_at | 2015-10-30 04:17:23.989177 |
updated_at | 2015-12-16 00:01:56.610782 |
description | Rust wrapper for libraw |
homepage | https://github.com/dcuddeback/libraw-rs |
repository | https://github.com/dcuddeback/libraw-rs |
max_upload_size | |
id | 3334 |
size | 4,075,668 |
The libraw
crate provides a safe wrapper around the native libraw
library.
In order to use the libraw
crate, you must have the libraw_r
library installed where it can be
found by pkg-config
. libraw_r
is the reentrant version of LibRaw. Linking against the non
reentrant libraw
is not supported.
On Debian-based Linux distributions, install the libraw-dev
package:
sudo apt-get install libraw-dev
On OS X, install libraw
with Homebrew:
brew install libraw
On FreeBSD, install the libraw
package:
sudo pkg install libraw
Add libraw
as a dependency in Cargo.toml
:
[dependencies]
libraw = "0.1"
Import the libraw
crate. Open an image with Image::open()
and then use the methods on Image
to
operate on and inspect the raw image data.
extern crate libraw;
use std::path::Path;
fn main() {
let mut image = libraw::Image::open(Path::new("image.nef")).unwrap();
image.unpack().unwrap();
let raw = image.raw_pixmap().unwrap();
let sum = raw.pixels().fold(0, |accum, pixel| {
accum + pixel.value() as usize
});
println!("average pixel brightness = {:.3}", sum as f64 / raw.len() as f64);
}
Copyright © 2015 David Cuddeback
Distributed under the MIT License.
Note: By using this crate, your executable will link to the libraw
C library, which is available
under the LGPL version 2.1, CDDL version 1.0, or LibRaw Software
License.