Rawkit Image Processing
Relevant source files
The following files were used as context for generating this wiki page:
Rawkit is a specialized Rust library developed for the Graphite project to handle the decoding and processing of raw photographs from professional digital cameras. Raw files contain compressed sensor imagery and metadata that require complex operations—such as demosaicing (debayering) and color space handling—to transform into viewable images.
As a core component of Graphite's mission to become a comprehensive photo editing suite, Rawkit provides a pure Rust, permissively licensed (MIT/Apache-2.0) alternative to existing GPL-licensed libraries. Its primary goal is to enable a nondestructive workflow for high-bit-depth sensor data within Graphite's node-based architecture.
Sources: website/content/volunteer/guide/student-projects/completed-projects.md:104-109, libraries/rawkit/Cargo.toml:13-15
Architecture and Development
Rawkit was initiated as a Google Summer of Code (GSoC) 2024 project. The library is architected to extract images from camera raw files using native Rust implementations, avoiding external C dependencies where possible to ensure portability and safety within Graphite's WebAssembly and desktop environments.
Component Structure
The following diagram illustrates the high-level data flow from a raw file through the Rawkit decoding pipeline.
The pipeline begins with a custom TIFF decoder to extract metadata and compressed sensor data, followed by processing stages to convert raw sensor readings into RGB pixels.
Sources: website/content/blog/2024-07-31-graphite-progress-report-q2-2024.md:139-145, website/content/volunteer/guide/student-projects/completed-projects.md:104-109
Library Dependencies
Rawkit utilizes several Rust crates for low-level bit manipulation and error handling.
| Dependency | Purpose |
|---|---|
bitstream-io | Reading bit-level data from compressed streams |
num_enum | Mapping numeric values to Rust enums for metadata |
thiserror | Structured error handling across the decoding process |
rawkit-proc-macros | Internal procedural macros for the library |
Sources: libraries/rawkit/Cargo.toml:23-28
Features and Format Support
The initial development of Rawkit focused on the Sony ARW format as the primary target for professional photography support in Graphite.
Support Summary
- Target Formats: Sony ARW was the first format implemented, with foundations laid for broader TIFF-based raw files.
- Decoding Capabilities: Implements custom TIFF decoding and Sony ARW data encoding format handling.
- Integration: Designed to output data compatible with Graphite's node graph, allowing raw processing to occur as a set of nondestructive nodes.
Sources: website/content/blog/2024-07-31-graphite-progress-report-q2-2024.md:139-145, website/content/volunteer/guide/student-projects/completed-projects.md:107-109
Integration with Graphite Node Graph
Rawkit serves as the backend engine for raw photo processing nodes. Within Graphite, raw image editing is handled as a description of operations rather than destructive alterations.
The interaction ensures that the original high-fidelity sensor data remains untouched, while Rawkit provides the necessary viewable representation for the editor's viewport.
Sources: website/content/features.md:197-200, website/content/volunteer/guide/student-projects/completed-projects.md:104-109
Project Significance
Before Rawkit, the Rust ecosystem lacked a pure-Rust, non-GPL library for raw photograph decoding. By developing this library, Graphite ensures it can support professional photography workflows while maintaining a permissive license structure. This enables features such as infinite zoom and scaling on raster-style images by recording the manipulations parametrically rather than destructively.
Sources: website/content/volunteer/guide/student-projects/completed-projects.md:107-109, website/content/features.md:55-58