Merge pull request #27 from little-bobby-tables/get-image-page
Add get_image_page to MagickWand
This commit is contained in:
commit
a1f211ad1f
3 changed files with 21 additions and 0 deletions
|
@ -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.
|
/// Retrieve the named image property value.
|
||||||
pub fn get_image_property(&self, name: &str) -> Result<String, &'static str> {
|
pub fn get_image_property(&self, name: &str) -> Result<String, &'static str> {
|
||||||
let c_name = CString::new(name).unwrap();
|
let c_name = CString::new(name).unwrap();
|
||||||
|
|
BIN
tests/data/rust.gif
Normal file
BIN
tests/data/rust.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
12
tests/lib.rs
12
tests/lib.rs
|
@ -208,3 +208,15 @@ fn test_set_option() {
|
||||||
assert_eq!(192, wand.get_image_width());
|
assert_eq!(192, wand.get_image_width());
|
||||||
assert_eq!(144, wand.get_image_height());
|
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());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue