From ccda94221fd8eebaae37ef3f3847230487a88e04 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 25 May 2018 16:00:40 -0400 Subject: [PATCH 1/4] Adding binding for MagickAddImage --- .gitignore | 1 + src/wand/magick.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 4d47cc9..25fd82e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.swp *.pyc Cargo.lock rust-bindgen diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 28bd0b0..ee23858 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -66,6 +66,13 @@ impl MagickWand { } } + 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 { From 3daa8e77e825cc189288e837dd5dce75e731b6d4 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 25 May 2018 16:39:59 -0400 Subject: [PATCH 2/4] adding docs & rotate_image --- src/wand/magick.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index ee23858..15e0a56 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -66,6 +66,7 @@ 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(()), @@ -238,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 { From 15a2fd7d1a4e965f4b1a294229c21fd15cae6ef4 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 25 May 2018 16:49:38 -0400 Subject: [PATCH 3/4] Making self mutable --- src/wand/magick.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 15e0a56..167b366 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -241,7 +241,7 @@ 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> { + pub fn rotate_image(&mut 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") From f694737ac5569da31e09c9988d56d6231bf5d009 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 25 May 2018 16:51:23 -0400 Subject: [PATCH 4/4] Revert "Making self mutable" This reverts commit 15a2fd7d1a4e965f4b1a294229c21fd15cae6ef4. --- src/wand/magick.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 167b366..15e0a56 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -241,7 +241,7 @@ 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(&mut self, background: &PixelWand, degrees: f64) -> Result<(), &'static str> { + 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")