Merge pull request #84 from walterbm/thumbnail-resize
Add support for "thumbnail" image resizing
This commit is contained in:
@ -691,6 +691,15 @@ impl MagickWand {
|
||||
}
|
||||
}
|
||||
|
||||
/// Resize the image to the specified width and height, using the
|
||||
/// 'thumbnail' optimizations which remove a lot of image meta-data with the goal
|
||||
/// of producing small low cost images suited for display on the web.
|
||||
pub fn thumbnail_image(&self, width: usize, height: usize) {
|
||||
unsafe {
|
||||
bindings::MagickThumbnailImage(self.wand, width as size_t, height as size_t);
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract a region of the image. The width and height is used as the size
|
||||
/// of the region. X and Y is the offset.
|
||||
pub fn crop_image(
|
||||
|
||||
23
tests/lib.rs
23
tests/lib.rs
@ -59,6 +59,29 @@ fn test_resize_image() {
|
||||
assert_eq!(192, wand.get_image_height());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_thumbnail_image() {
|
||||
START.call_once(|| {
|
||||
magick_wand_genesis();
|
||||
});
|
||||
let wand = MagickWand::new();
|
||||
assert!(wand.read_image("tests/data/IMG_5745.JPG").is_ok());
|
||||
assert_eq!(512, wand.get_image_width());
|
||||
assert_eq!(384, wand.get_image_height());
|
||||
let halfwidth = match wand.get_image_width() {
|
||||
1 => 1,
|
||||
width => width / 2,
|
||||
};
|
||||
let halfheight = match wand.get_image_height() {
|
||||
1 => 1,
|
||||
height => height / 2,
|
||||
};
|
||||
wand.thumbnail_image(halfwidth, halfheight);
|
||||
assert_eq!(256, wand.get_image_width());
|
||||
assert_eq!(192, wand.get_image_height());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_read_from_blob() {
|
||||
START.call_once(|| {
|
||||
|
||||
Reference in New Issue
Block a user