| Crates.io | rsraw-sys |
| lib.rs | rsraw-sys |
| version | 0.1.0 |
| created_at | 2025-09-27 08:12:43.33208+00 |
| updated_at | 2025-09-27 08:12:43.33208+00 |
| description | Low-level FFI bindings for the LibRaw C++ library |
| homepage | https://github.com/hexilee/rsraw |
| repository | https://github.com/hexilee/rsraw |
| max_upload_size | |
| id | 1857073 |
| size | 2,157,592 |
A comprehensive Rust wrapper for the LibRaw library, providing safe and idiomatic access to raw image processing capabilities, works on Linux/Windows/MacOS/iOS/Android.
This workspace contains two main crates that work together to provide raw image file support for Rust applications.
rsraw provides Rust bindings for the LibRaw C++ library, enabling developers to read, process, and extract metadata from raw image files from various camera manufacturers. The library supports over 400 camera models and provides access to both raw image data and processed images.
This workspace contains two main crates:
rsraw-sys - Low-level FFI bindingsbindgencc cratersraw - High-level Rust APIserdeDrop implementationsResult<T, Error>Add the following to your Cargo.toml:
[dependencies]
rsraw = { git = "https://github.com/hexilee/rsraw.git" }
Or add both crates if you need low-level access:
[dependencies]
rsraw = { git = "https://github.com/hexilee/rsraw.git" }
rsraw-sys = { git = "https://github.com/hexilee/rsraw.git", package = "rsraw-sys" }
Alternatively, you can specify a specific branch or commit:
[dependencies]
rsraw = { git = "https://github.com/hexilee/rsraw.git", branch = "main" }
# or
rsraw = { git = "https://github.com/hexilee/rsraw.git", rev = "abc1234" }
use rsraw::{RawImage, BIT_DEPTH_16};
// Load raw image from file
let data = std::fs::read("image.ARW")?;
let mut raw_image = RawImage::open(&data)?;
// Extract metadata
let info = raw_image.full_info();
println!("Camera: {} {}", info.make, info.model);
println!("ISO: {}, Shutter: 1/{}s, Aperture: f/{}",
info.iso_speed,
(1.0 / info.shutter) as u32,
info.aperture);
// Process image to 16-bit
raw_image.unpack()?;
let processed = raw_image.process::<BIT_DEPTH_16>()?;
println!("Processed image: {}x{} pixels", processed.width(), processed.height());
use rsraw::RawImage;
let mut raw_image = RawImage::open(&data)?;
// Basic image properties
println!("Dimensions: {}x{}", raw_image.width(), raw_image.height());
println!("Colors: {}", raw_image.colors());
// Camera and lens information
let lens_info = raw_image.lens_info();
println!("Lens: {} {}", lens_info.lens_make, lens_info.lens_name);
println!("Focal length: {}mm", lens_info.min_focal);
println!("Mount: {}", lens_info.mounts);
// GPS information
let gps = raw_image.gps();
if gps.latitude[0] != 0.0 {
println!("GPS: {:.6}, {:.6}", gps.latitude[0], gps.longitude[0]);
}
use rsraw::RawImage;
let mut raw_image = RawImage::open(&data)?;
let thumbnails = raw_image.extract_thumbs()?;
for thumb in thumbnails {
println!("Thumbnail: {}x{} ({:?})",
thumb.width, thumb.height, thumb.format);
// Save thumbnail data
std::fs::write("thumb.jpg", &thumb.data)?;
}
RawImage: Main struct for raw image processingProcessedImage<D>: Processed image data with configurable bit depthFullRawInfo: Complete metadata structureLensInfo: Detailed lens informationGpsInfo: GPS coordinates and altitudeThumbnailImage: Thumbnail data with format informationopen(data: &[u8]) -> Result<Self>: Load raw image from byte bufferunpack() -> Result<()>: Unpack raw data for processingprocess<const D: BitDepth>() -> Result<ProcessedImage<D>>: Process imageextract_thumbs() -> Result<Vec<ThumbnailImage>>: Extract thumbnailsfull_info() -> FullRawInfo: Get complete metadatawidth() -> u32: Image width in pixelsheight() -> u32: Image height in pixelscolors() -> u16: Number of color channelsbits() -> u16: Bits per sampledata_size() -> usize: Total data size in bytesThe library supports raw formats from major camera manufacturers:
libc, cc, bindgenrsraw-sys, chrono, tracing, serdeThe library requires a C++ compiler and the LibRaw source code (included as a submodule). The build process:
bindgenRun the test suite:
cargo test --all
The tests include sample raw files from Nikon and Sony cameras to verify functionality.
This project is licensed under the MIT License. See the LICENSE file for details.
The underlying LibRaw library has its own licensing terms. Please refer to the LibRaw documentation for information about its license and usage restrictions.
Contributions are welcome! Please feel free to submit issues and pull requests.