Merge pull request #42 from NQNStudios/new-bindings

Adding binding for MagickAddImage and MagicRotateImage
This commit is contained in:
Nathan Fiedler
2018-05-25 15:16:14 -07:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.swp
*.pyc
Cargo.lock
rust-bindgen

View File

@ -66,6 +66,14 @@ impl MagickWand {
}
}
/// Add all images from another wand to this wand at the current index.
pub fn add_image(&mut self, other_wand: &MagickWand) -> Result<(), &'static str> {
match unsafe { bindings::MagickAddImage(self.wand, other_wand.wand) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
_ => Err("unable to add images from another wand")
}
}
pub fn append_all(&mut self, stack: bool) -> MagickWand {
unsafe { bindings::MagickResetIterator(self.wand) };
MagickWand {
@ -231,6 +239,15 @@ impl MagickWand {
}
}
/// Rotate the currently selected image by the given number of degrees,
/// filling any empty space with the background color of a given PixelWand
pub fn rotate_image(&self, background: &PixelWand, degrees: f64) -> Result<(), &'static str> {
match unsafe { bindings::MagickRotateImage(self.wand, background.wand, degrees) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
_ => Err("failed to rotate image")
}
}
/// Trim the image removing the backround color from the edges.
pub fn trim_image(&self, fuzz: f64) -> Result<(), &'static str> {
let result = unsafe {