49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
use std::path::Path;
|
|
|
|
fn main() {
|
|
let path = Path::new("/home/hc/Pictures/_psd_stil_test/sultan.psd");
|
|
if !path.exists() {
|
|
println!("File not found");
|
|
return;
|
|
}
|
|
|
|
let bytes = std::fs::read(path).unwrap();
|
|
|
|
// 1. Direct parse (raw hcie_fx effects)
|
|
let parsed = hcie_psd::psd_import::parse_psd_sequential(&bytes).unwrap();
|
|
let mut direct_fx: Vec<Vec<hcie_fx::LayerEffect>> = Vec::new();
|
|
for p in &parsed {
|
|
if !p.is_group {
|
|
direct_fx.push(p.effects.clone());
|
|
}
|
|
}
|
|
|
|
// 2. Protocol round-trip
|
|
let layers = hcie_psd::import_psd(path).unwrap();
|
|
let mut roundtrip_fx: Vec<Vec<hcie_fx::LayerEffect>> = Vec::new();
|
|
for layer in &layers {
|
|
let converted: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(|e| hcie_fx::protocol_to_hcie_fx_effect(e)).collect();
|
|
roundtrip_fx.push(converted);
|
|
}
|
|
|
|
// Compare
|
|
println!("Direct count: {}, Round-trip count: {}", direct_fx.len(), roundtrip_fx.len());
|
|
let mut diffs = 0;
|
|
for (i, (d, r)) in direct_fx.iter().zip(roundtrip_fx.iter()).enumerate() {
|
|
if d.len() != r.len() {
|
|
println!("Layer {}: different effect count {} vs {}", i, d.len(), r.len());
|
|
diffs += 1;
|
|
continue;
|
|
}
|
|
for (j, (de, re)) in d.iter().zip(r.iter()).enumerate() {
|
|
if format!("{:?}", de) != format!("{:?}", re) {
|
|
println!("Layer {} effect {} DIFFERS:", i, j);
|
|
println!(" Direct: {:?}", de);
|
|
println!(" Roundtri: {:?}", re);
|
|
diffs += 1;
|
|
}
|
|
}
|
|
}
|
|
println!("Total differences: {}", diffs);
|
|
}
|