diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 048a03a..a8fbc30 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -152,6 +152,15 @@ impl MagickWand { } } + /// Retrieve the page geometry (width, height, x offset, y offset) of the image. + pub fn get_image_page(&self) -> (usize, usize, isize, isize) { + let (mut width, mut height, mut x, mut y) = (0usize, 0usize, 0isize, 0isize); + unsafe { + bindings::MagickGetImagePage(self.wand, &mut width, &mut height, &mut x, &mut y); + } + (width, height, x, y) + } + /// Retrieve the named image property value. pub fn get_image_property(&self, name: &str) -> Result { let c_name = CString::new(name).unwrap(); diff --git a/tests/data/rust.gif b/tests/data/rust.gif new file mode 100644 index 0000000..06a1fde Binary files /dev/null and b/tests/data/rust.gif differ diff --git a/tests/lib.rs b/tests/lib.rs index 94b5ed5..6002e21 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -208,3 +208,15 @@ fn test_set_option() { assert_eq!(192, wand.get_image_width()); assert_eq!(144, wand.get_image_height()); } + +#[test] +fn test_page_geometry() { + START.call_once(|| { + magick_wand_genesis(); + }); + let wand = MagickWand::new(); + assert!(wand.read_image("tests/data/rust.gif").is_ok()); + assert_eq!((156, 150, 39, 36), wand.get_image_page()); /* width, height, x offset, y offset */ + assert_eq!(80, wand.get_image_width()); + assert_eq!(76, wand.get_image_height()); +}