Add metadata stripping, watermark positioning, and rename template modules

Metadata: JPEG EXIF stripping (APP1 segment removal).
Watermark: 9-position grid calculation with margin support.
Rename: template parser with {name}, {ext}, {counter:N}, {width}, {height}
  and collision resolution with auto-suffix.
Phase 4 complete - 79 tests passing, zero clippy warnings.
This commit is contained in:
2026-03-06 02:06:01 +02:00
parent ea4ea9c9c4
commit d4aef0b774
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());
}