From ce5dc1d4f9acc81fd9adab2d20b45c7ab148602d Mon Sep 17 00:00:00 2001 From: Justin Shrake Date: Sun, 5 Feb 2023 20:33:38 -0800 Subject: [PATCH] Add MagickAutoGammaImage and MagickAutoLevelImage --- src/wand/magick.rs | 6 ++++++ tests/lib.rs | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index a3cdbc8..500f0fd 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -1015,6 +1015,12 @@ impl MagickWand { /// Applies k-means color reduction to the image. MagickKmeansImage => kmeans(number_colors: size_t, max_iterations: size_t, tolerance: f64) + + /// Extracts the 'mean' from the image and adjust the image to try make set its gamma appropriately. + MagickAutoGammaImage => auto_gamma() + + /// Adjusts the levels of a particular image channel by scaling the minimum and maximum values to the full quantum range. + MagickAutoLevelImage => auto_level() ); get!(get_image_colors, MagickGetImageColors, size_t); diff --git a/tests/lib.rs b/tests/lib.rs index 72c6a7c..08b4138 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -396,3 +396,23 @@ fn test_resource_limits() { let wand = MagickWand::new(); assert!(wand.read_image("tests/data/rust.png").is_ok()); } + +#[test] +fn test_auto_level() { + START.call_once(|| { + magick_wand_genesis(); + }); + let wand = MagickWand::new(); + assert!(wand.read_image("tests/data/IMG_5745.JPG").is_ok()); + assert!(wand.auto_level().is_ok()); +} + +#[test] +fn test_auto_gamma() { + START.call_once(|| { + magick_wand_genesis(); + }); + let wand = MagickWand::new(); + assert!(wand.read_image("tests/data/IMG_5745.JPG").is_ok()); + assert!(wand.auto_gamma().is_ok()); +}