1 unstable release

0.1.0 Nov 3, 2024

#278 in Images

MIT/Apache

64KB
2K SLoC

crates.iodocs.rsrepo

Rawkit 🚀

A library to extract images from camera raw files.

It currently only works with the .arw files from Sony's cameras. In the future, the library will add support for all other major camera manufacturers.

Rawkit is built for the needs of Graphite, an open source 2D graphics editor. We hope it may be useful to others, but presently Graphite is its primary user. Pull requests are welcomed for new cameras, features, code cleanup, ergonomic enhancements, performance improvements, and documentation clarifications.

Using Rawkit

use rawkit::RawImage;
use rawkit::tiff::values::Transform;

// Open a file for reading
let file = BufReader::new(File::open("example.arw")?);

// Decode the file to extract the raw pixels and its associated metadata
let mut raw_image = RawImage::decode(file);

// All the raw pixel data and metadata is stored within `raw_image`
println!("Initial Bayer pixel values: {:?}", raw_image.data[:10]);
println!("Image size: {} x {}", raw_image.width, raw_image.height);
println!("CFA Pattern: {:?}", raw_image.cfa_pattern);
println!("Camera Model: {:?}", raw_image.camera_model);
println!("White balance: {:?}", raw_image.white_balance);

// The metadata could also be edited if the extracted metadata needs to be customized
raw_image.white_balance = Some([2609, 1024, 1024, 1220]); // For RGGB camera
raw_image.transform = Transform::Rotate90;

// Process the raw image into an RGB image
let image = raw_image.process_8bit();

// The final image data will be stored within `image`
println!("Initial RGB pixel values: {:?}", image.data[:10]);
println!("Image size: {} x {}", image.width, image.height);

Dependencies

~0.7–12MB
~147K SLoC