raw_preview_rs
A Rust library designed to quickly create preview JPEGs from RAW image files and extract comprehensive EXIF metadata.
‼️ This library is optimized for compatibility; hence, it comes with an involved build process to statically link the C/C++ dependencies, requiring several build tools.
This library/crate is in early development.
Features
- RAW Image Processing: Supports 27+ RAW formats, including CR2, NEF, ARW, RAF, and more.
- Standard Image Formats: Handles JPEG, PNG, TIFF, BMP, and WebP.
- EXIF Metadata Extraction: Extracts and preserves EXIF metadata, including camera make, model, ISO, and more.
- Resolution Reduction: Automatically reduces image resolution for fast previews.
Installation
Add this to your Cargo.toml:
[]
= "0.1.1"
First Build
The first build will take longer (≈ 5 minutes) as it downloads and compiles all native dependencies. Subsequent builds will be much faster as dependencies are cached.
# Clean build (if needed)
# Build with full output
# Or build and run tests
Usage
Example: Processing a RAW File
use process_any_image;
match process_any_image
Example: Processing a JPEG File
use process_any_image;
match process_any_image
Supported Formats
RAW Formats (processed via LibRaw):
- Canon: CR2, CR3
- Nikon: NEF
- Sony: ARW, SR2, SRF
- Fujifilm: RAF
- Panasonic: RW2
- Olympus: ORF
- Pentax: PEF, PTX
- Samsung: SRW
- Hasselblad: 3FR, FFF
- Mamiya: MEF
- Minolta: MRW, MDC
- Sigma: X3F
- Kodak: DCR, KDC
- PhaseOne: IIQ, CAP
- Leica: RWL
- GoPro: GPR
- Epson: ERF
- Leaf: MOS
- RED: R3D
- Adobe: DNG
- Generic: RAW
Standard Image Formats:
- JPEG: JPG, JPEG
- PNG: PNG
- TIFF: TIFF, TIF
- Bitmap: BMP
- WebP: WEBP
Build Requirements
This library has several native dependencies that are automatically downloaded and built during compilation. To ensure a successful build, you need the following tools installed on your system:
Required Build Tools
All Platforms
-
CMake (version 3.10 or higher)
- Used for building TinyEXIF and TinyXML2
- Download from: https://cmake.org/download/
-
Make
- Used for building all dependencies
- Usually pre-installed on Unix-like systems
macOS
# Install Xcode Command Line Tools (includes make, clang, etc.)
# Install CMake using Homebrew
# Install autotools (recommended for LibRaw)
Ubuntu/Debian
# Install build essentials and CMake
# Install autotools (recommended for LibRaw)
CentOS/RHEL/Fedora
# Install build tools and CMake
# Install autotools (recommended for LibRaw)
Windows
- Visual Studio (2019 or later) with C++ build tools
- CMake - Download from https://cmake.org/download/
- Git (for downloading dependencies)
Alternatively, use vcpkg or Conan to manage dependencies.
Optional Tools
- autoconf, automake, libtool: Recommended for building LibRaw from source
- If these are not available, the build script will attempt to use pre-generated configure scripts
- Without these tools, some LibRaw versions may fail to build
Automatic Dependency Management
The following dependencies are automatically downloaded and built during compilation:
- zlib 1.3 - Compression library
- LibRaw 0.21.4 - RAW image processing
- libjpeg-turbo 2.1.5 - JPEG compression/decompression
- TinyEXIF 1.0.3 - EXIF metadata extraction
- TinyXML2 11.0.0 - XML parsing for XMP metadata
- stb_image - Standard image format decoding
All dependencies are statically linked into the final library, so end users don't need to install anything separately.
Build Troubleshooting
If you encounter build issues:
- Missing autotools: Install autoconf, automake, and libtool
- CMake not found: Ensure CMake is in your PATH
- Compiler errors: Ensure you have a C++11 compatible compiler
- Network issues: The build downloads dependencies from the internet
For detailed error messages, run:
RUST_BACKTRACE=1
Cross-compilation
Cross-compilation is supported but requires the target platform's build tools. Ensure CMake and make are available for your target platform.
Dependencies
This library automatically manages all its native dependencies through a custom build script. The following libraries are downloaded, compiled, and statically linked during the build process:
| Dependency | Version | Purpose | Source |
|---|---|---|---|
| zlib | 1.3 | Compression library | zlib.net |
| LibRaw | 0.21.4 | RAW image processing | GitHub |
| libjpeg-turbo | 2.1.5 | JPEG compression/decompression | GitHub |
| TinyEXIF | 1.0.3 | EXIF metadata extraction | GitHub |
| TinyXML2 | 11.0.0 | XML parsing for XMP metadata | GitHub |
| stb_image | latest | Standard image format decoding | GitHub |
Dependency Management Features
- Automatic Download: All dependencies are downloaded from their official sources
- Version Pinning: Specific versions are used to ensure build reproducibility
- Static Linking: All libraries are statically linked for easy deployment
- Caching: Built dependencies are cached to speed up subsequent builds
- Cross-platform: Works on macOS, Linux, and Windows with appropriate build tools
No manual dependency installation is required - just ensure you have the build tools listed above.
License
This project is licensed under the GNU General Public License (GPL) version 3. See the LICENSE file for details.