- Move watermark step after compress in processing pipeline to match design doc order (resize, adjustments, convert, compress, metadata, watermark, rename) - Implement selective EXIF metadata stripping for Privacy and Custom modes using little_exif tag filtering (GPS, camera, software, timestamps, copyright categories) - Add case conversion support to rename (none/lower/upper/title) - Add regex find-and-replace on original filenames - Wire case and regex controls in rename step UI to JobConfig - Add regex crate dependency to pixstrip-core
118 lines
3.3 KiB
Rust
118 lines
3.3 KiB
Rust
use pixstrip_core::operations::*;
|
|
use pixstrip_core::types::*;
|
|
|
|
#[test]
|
|
fn resize_config_width_only() {
|
|
let config = ResizeConfig::ByWidth(1200);
|
|
assert_eq!(
|
|
config.target_for(Dimensions { width: 4000, height: 3000 }),
|
|
Dimensions { width: 1200, height: 900 }
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn resize_config_fit_in_box() {
|
|
let config = ResizeConfig::FitInBox {
|
|
max: Dimensions { width: 1920, height: 1080 },
|
|
allow_upscale: false,
|
|
};
|
|
let result = config.target_for(Dimensions { width: 4000, height: 3000 });
|
|
assert_eq!(result.width, 1440);
|
|
assert_eq!(result.height, 1080);
|
|
}
|
|
|
|
#[test]
|
|
fn resize_config_exact() {
|
|
let config = ResizeConfig::Exact(Dimensions { width: 1080, height: 1080 });
|
|
assert_eq!(
|
|
config.target_for(Dimensions { width: 4000, height: 3000 }),
|
|
Dimensions { width: 1080, height: 1080 }
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn metadata_config_strip_all() {
|
|
let config = MetadataConfig::StripAll;
|
|
assert!(config.should_strip_gps());
|
|
assert!(config.should_strip_camera());
|
|
assert!(config.should_strip_copyright());
|
|
}
|
|
|
|
#[test]
|
|
fn metadata_config_privacy() {
|
|
let config = MetadataConfig::Privacy;
|
|
assert!(config.should_strip_gps());
|
|
assert!(config.should_strip_camera());
|
|
assert!(!config.should_strip_copyright());
|
|
}
|
|
|
|
#[test]
|
|
fn metadata_config_keep_all() {
|
|
let config = MetadataConfig::KeepAll;
|
|
assert!(!config.should_strip_gps());
|
|
assert!(!config.should_strip_camera());
|
|
assert!(!config.should_strip_copyright());
|
|
}
|
|
|
|
#[test]
|
|
fn convert_config_single_format() {
|
|
let config = ConvertConfig::SingleFormat(ImageFormat::WebP);
|
|
assert_eq!(config.output_format(ImageFormat::Jpeg), ImageFormat::WebP);
|
|
assert_eq!(config.output_format(ImageFormat::Png), ImageFormat::WebP);
|
|
}
|
|
|
|
#[test]
|
|
fn convert_config_keep_original() {
|
|
let config = ConvertConfig::KeepOriginal;
|
|
assert_eq!(config.output_format(ImageFormat::Jpeg), ImageFormat::Jpeg);
|
|
assert_eq!(config.output_format(ImageFormat::Png), ImageFormat::Png);
|
|
}
|
|
|
|
#[test]
|
|
fn watermark_position_all_nine() {
|
|
let positions = [
|
|
WatermarkPosition::TopLeft,
|
|
WatermarkPosition::TopCenter,
|
|
WatermarkPosition::TopRight,
|
|
WatermarkPosition::MiddleLeft,
|
|
WatermarkPosition::Center,
|
|
WatermarkPosition::MiddleRight,
|
|
WatermarkPosition::BottomLeft,
|
|
WatermarkPosition::BottomCenter,
|
|
WatermarkPosition::BottomRight,
|
|
];
|
|
assert_eq!(positions.len(), 9);
|
|
}
|
|
|
|
#[test]
|
|
fn rename_config_simple_template() {
|
|
let config = RenameConfig {
|
|
prefix: "blog_".into(),
|
|
suffix: String::new(),
|
|
counter_start: 1,
|
|
counter_padding: 3,
|
|
template: None,
|
|
case_mode: 0,
|
|
regex_find: String::new(),
|
|
regex_replace: String::new(),
|
|
};
|
|
let result = config.apply_simple("sunset", "jpg", 1);
|
|
assert_eq!(result, "blog_sunset_001.jpg");
|
|
}
|
|
|
|
#[test]
|
|
fn rename_config_with_suffix() {
|
|
let config = RenameConfig {
|
|
prefix: String::new(),
|
|
suffix: "_web".into(),
|
|
counter_start: 1,
|
|
counter_padding: 2,
|
|
template: None,
|
|
case_mode: 0,
|
|
regex_find: String::new(),
|
|
regex_replace: String::new(),
|
|
};
|
|
let result = config.apply_simple("photo", "webp", 5);
|
|
assert_eq!(result, "photo_web_05.webp");
|
|
}
|