Add a fit function to resize an image
Given a bounding box defined by the desired width and height, resize the image to fit that box, maintaining the aspect ratio. cargo test passes
This commit is contained in:
14
tests/lib.rs
14
tests/lib.rs
@ -97,3 +97,17 @@ fn test_write_to_blob() {
|
||||
assert_eq!(512, wand.get_image_width());
|
||||
assert_eq!(384, wand.get_image_height());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fit() {
|
||||
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());
|
||||
wand.fit(240, 240);
|
||||
assert_eq!(240, wand.get_image_width());
|
||||
assert_eq!(180, wand.get_image_height());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user