From 4dda874de11149d1d26e7556bc776ec4df32af9b Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 10 Oct 2020 17:42:35 -0500 Subject: [PATCH] Add sample method --- src/wand/magick.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 153f4f3..a94d991 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -677,6 +677,18 @@ impl MagickWand { } } + /// Sample the image to the target resolution + /// + /// This is incredibly fast, as it does 1-1 pixel mapping for downscales, and box filtering for + /// upscales + pub fn sample_image(&self, width: usize, height: usize) -> Result<(), &'static str> { + let result = unsafe { bindings::MagickSampleImage(self.wand, width, height) }; + match result { + bindings::MagickBooleanType_MagickTrue => Ok(()), + _ => Err("failed to sample image"), + } + } + /// Resample the image to the specified horizontal and vertical resolution, using the /// specified filter type. pub fn resample_image(