| Crates.io | metastrip |
| lib.rs | metastrip |
| version | 0.1.0 |
| created_at | 2026-01-22 06:53:25.591335+00 |
| updated_at | 2026-01-22 06:53:25.591335+00 |
| description | Extract and strip metadata from image files (JPEG, PNG, TIFF, WebP) |
| homepage | https://github.com/NumberSix-io/metastrip |
| repository | https://github.com/NumberSix-io/metastrip |
| max_upload_size | |
| id | 2060904 |
| size | 123,853 |
A fast, safe Rust library for extracting and stripping metadata from image files.
| Format | Extract | Strip | Endianness |
|---|---|---|---|
| JPEG | ✅ | ✅ | - |
| PNG | ✅ | ✅ | - |
| TIFF | ✅ | ✅ | Both (II/MM) |
| WebP | ✅ | ✅ | - |
Add this to your Cargo.toml:
[dependencies]
metastrip = "0.1.0"
use metastrip;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read image file
let image_data = std::fs::read("photo.jpg")?;
// Extract all metadata
let metadata = metastrip::extract_metadata(&image_data)?;
// Access different metadata types
if let Some(exif) = metadata.exif {
println!("Found {} EXIF fields", exif.fields.len());
for (key, value) in exif.fields {
println!("{}: {:?}", key, value);
}
}
if let Some(xmp) = metadata.xmp {
println!("XMP data: {}", xmp.raw_xml);
}
if let Some(icc) = metadata.icc_profile {
println!("ICC profile: {} bytes", icc.data.len());
if let Some(desc) = icc.description {
println!("Profile: {}", desc);
}
}
Ok(())
}
use metastrip;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read image file
let image_data = std::fs::read("photo.jpg")?;
// Strip all metadata (lossless operation)
let clean_image = metastrip::strip_metadata(&image_data)?;
// Save cleaned image
std::fs::write("photo_clean.jpg", clean_image)?;
// Verify metadata is removed
let metadata = metastrip::extract_metadata(&clean_image)?;
assert!(metadata.exif.is_none());
assert!(metadata.xmp.is_none());
Ok(())
}
Unlike tools that decode and re-encode images, metastrip operates at the byte level:
This approach is:
Metadata stripping is designed to be fast:
pub fn extract_metadata(bytes: &[u8]) -> Result<Metadata>
pub fn strip_metadata(bytes: &[u8]) -> Result<Vec<u8>>
pub struct Metadata {
pub format: ImageFormat,
pub exif: Option<ExifData>,
pub iptc: Option<IptcData>,
pub xmp: Option<XmpData>,
pub icc_profile: Option<IccProfile>,
}
pub enum ImageFormat {
Jpeg,
Png,
Tiff,
WebP,
}
See the API documentation for complete details.
The library includes comprehensive tests:
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_jpeg_stripping
Contributions are welcome! Please feel free to submit a Pull Request.
Licensed under either of:
at your option.