Add compare_images method

This commit is contained in:
gentoo90
2017-05-16 16:43:08 +03:00
parent 4a5b6935ed
commit c50b3e27de
3 changed files with 35 additions and 1 deletions

View File

@ -16,7 +16,7 @@
extern crate magick_rust;
use magick_rust::{MagickWand, magick_wand_genesis};
use magick_rust::{MagickWand, magick_wand_genesis, MetricType};
use std::error::Error;
use std::fs::File;
@ -177,6 +177,23 @@ fn test_auto_orient() {
assert_eq!(false, wand.requires_orientation());
}
#[test]
fn test_compare_images() {
START.call_once(|| {
magick_wand_genesis();
});
let wand1 = MagickWand::new();
assert!(wand1.read_image("tests/data/IMG_5745.JPG").is_ok());
let wand2 = MagickWand::new();
assert!(wand2.read_image("tests/data/IMG_5745_rotl.JPG").is_ok());
wand2.auto_orient();
let (distortion, diff) = wand1.compare_images(&wand2, MetricType::RootMeanSquaredErrorMetric);
assert!(distortion < 0.01);
assert!(diff.is_some());
}
#[test]
fn test_set_option() {
START.call_once(|| {