Graphite/libraries/rawkit
Dennis Kobert beb1c6ae64
Upgrade to the Rust 2024 edition (#2367)
* Update to rust 2024 edition

* Fixes

* Clean up imports

* Cargo fmt again

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2025-03-12 17:29:12 -07:00
..
camera_data/Sony Rename Raw-rs to Rawkit (#2088) 2024-11-03 08:10:39 +00:00
rawkit-proc-macros Upgrade to the Rust 2024 edition (#2367) 2025-03-12 17:29:12 -07:00
src Upgrade to the Rust 2024 edition (#2367) 2025-03-12 17:29:12 -07:00
tests Upgrade to the Rust 2024 edition (#2367) 2025-03-12 17:29:12 -07:00
.gitignore Rename Raw-rs to Rawkit (#2088) 2024-11-03 08:10:39 +00:00
Cargo.lock Update dependencies throughout the project (#2401) 2025-03-07 21:32:52 -08:00
Cargo.toml Upgrade to the Rust 2024 edition (#2367) 2025-03-12 17:29:12 -07:00
LICENSE-APACHE Rename Raw-rs to Rawkit (#2088) 2024-11-03 08:10:39 +00:00
LICENSE-MIT Rename Raw-rs to Rawkit (#2088) 2024-11-03 08:10:39 +00:00
README.md Rename Raw-rs to Rawkit (#2088) 2024-11-03 08:10:39 +00:00

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