metastrip
A fast, safe Rust library for extracting and stripping metadata from image files.
Features
- Extract metadata from images (EXIF, IPTC, XMP, ICC profiles)
- Strip metadata completely while preserving image quality (lossless)
- Multiple formats: JPEG, PNG, TIFF, WebP
- Zero unsafe code: Built with safety in mind
- Fast: Byte-level manipulation, no image decoding/encoding
- Memory efficient: Single-pass streaming approach
Supported Formats
| Format | Extract | Strip | Endianness |
|---|---|---|---|
| JPEG | ✅ | ✅ | - |
| PNG | ✅ | ✅ | - |
| TIFF | ✅ | ✅ | Both (II/MM) |
| WebP | ✅ | ✅ | - |
Supported Metadata Types
- EXIF - Camera settings, timestamps, GPS data
- IPTC - Photo journalism metadata (captions, keywords, copyright)
- XMP - Adobe extensible metadata (editing history, etc.)
- ICC Color Profiles - Color space information
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Extract Metadata
use metastrip;
Strip Metadata
use metastrip;
How It Works
Lossless Stripping
Unlike tools that decode and re-encode images, metastrip operates at the byte level:
- JPEG: Parses segments, removes APP markers containing metadata
- PNG: Parses chunks, keeps only critical chunks (IHDR, PLTE, IDAT, IEND, tRNS)
- TIFF: Parses IFD structure, rebuilds with only essential tags
- WebP: Parses RIFF container, rebuilds without metadata chunks
This approach is:
- ✅ Fast - No expensive decode/encode operations
- ✅ Lossless - Preserves original image quality
- ✅ Memory efficient - Single-pass processing
Performance
Metadata stripping is designed to be fast:
- Format detection: < 1µs
- JPEG strip (10MB): ~50ms
- PNG strip (10MB): ~100ms
- Zero-copy operations where possible
API Documentation
Main Functions
Types
See the API documentation for complete details.
Security
- ✅ No unsafe code - Built entirely with safe Rust
- ✅ Bounds checking - All array accesses are validated
- ✅ Input validation - File sizes, segment lengths, and offsets are checked
- ✅ DoS protection - Reasonable limits on metadata size
Testing
The library includes comprehensive tests:
# Run all tests
# Run with output
# Run specific test
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Acknowledgments
- kamadak-exif - EXIF parsing
- quick-xml - XMP (XML) parsing