Add metadata stripping, watermark positioning, and rename template modules

This commit is contained in:
2026-03-06 02:06:01 +02:00
parent 56f0a7172e
commit c81e2364af
7 changed files with 439 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
use pixstrip_core::operations::MetadataConfig;
use pixstrip_core::operations::metadata::strip_metadata;
use std::path::Path;
fn create_test_jpeg(path: &Path) {
let img = image::RgbImage::from_fn(100, 80, |x, y| {
image::Rgb([(x % 256) as u8, (y % 256) as u8, 128])
});
img.save_with_format(path, image::ImageFormat::Jpeg).unwrap();
}
#[test]
fn strip_all_metadata_produces_file() {
let dir = tempfile::tempdir().unwrap();
let input = dir.path().join("test.jpg");
let output = dir.path().join("stripped.jpg");
create_test_jpeg(&input);
strip_metadata(&input, &output, &MetadataConfig::StripAll).unwrap();
assert!(output.exists());
assert!(std::fs::metadata(&output).unwrap().len() > 0);
}
#[test]
fn keep_all_metadata_copies_file() {
let dir = tempfile::tempdir().unwrap();
let input = dir.path().join("test.jpg");
let output = dir.path().join("kept.jpg");
create_test_jpeg(&input);
strip_metadata(&input, &output, &MetadataConfig::KeepAll).unwrap();
assert!(output.exists());
}
#[test]
fn privacy_mode_strips_gps() {
let dir = tempfile::tempdir().unwrap();
let input = dir.path().join("test.jpg");
let output = dir.path().join("privacy.jpg");
create_test_jpeg(&input);
strip_metadata(&input, &output, &MetadataConfig::Privacy).unwrap();
assert!(output.exists());
}