diff --git a/image.go b/image.go index 4f3c8be..5279855 100644 --- a/image.go +++ b/image.go @@ -65,6 +65,12 @@ func (im *Image) Delay() int { return int(im.image.delay) } +// Strip removes all profiles and text attributes from the image. +func (im *Image) Strip() bool { + success := int(C.StripImage(im.image)) + return success > 0 +} + // Clone returns a copy of the image. If the image // has multiple frames, it copies all of them. To // Clone just one frame use im.Frame(i).Clone(). diff --git a/shear.go b/shear.go index f41c387..b5a52fb 100644 --- a/shear.go +++ b/shear.go @@ -2,6 +2,7 @@ package magick // #include // #include "bridge.h" +// #include "shear.h" import "C" // AffineTransform returns a new image created by transforming diff --git a/shear.h b/shear.h new file mode 100644 index 0000000..0fb548c --- /dev/null +++ b/shear.h @@ -0,0 +1,6 @@ +#ifndef SHEAR_H +#define SHEAR_H + +Image * rotateImage(Image *image, void *data, ExceptionInfo *ex); + +#endif diff --git a/shear_gm.c b/shear_gm.c new file mode 100644 index 0000000..7c940d7 --- /dev/null +++ b/shear_gm.c @@ -0,0 +1,11 @@ +// +build gm + +#include +#include "shear.h" + +Image * +rotateImage(Image *image, void *data, ExceptionInfo *ex) +{ + double *d = data; + return RotateImage(image, *d, ex); +} diff --git a/shear_gm.go b/shear_gm.go new file mode 100644 index 0000000..e560476 --- /dev/null +++ b/shear_gm.go @@ -0,0 +1,34 @@ +// +build gm + +package magick + +// #include +// #include "bridge.h" +// #include "shear.h" +import "C" + +// Rotate creates a new image that is a rotated copy of an existing one. Positive angles rotate counter-clockwise (right-hand rule), while negative angles rotate clockwise. +func (im *Image) Rotate(degrees float64) (*Image, error) { + data := C.double(degrees) + frames := im.NFrames() + newImage, err := im.First().applyDataFunc("rotating", C.ImageDataFunc(C.rotateImage), &data) + if err != nil { + return nil, err + } + for i := 1; i < frames; i++ { + frame, err := im.Frame(i) + if err != nil { + return nil, err + } + newFrame, err := frame.applyDataFunc("rotating", C.ImageDataFunc(C.rotateImage), &data) + if err != nil { + return nil, err + } + err = newImage.Append(newFrame) + if err != nil { + return nil, err + } + } + return newImage.Coalesce() +} + \ No newline at end of file diff --git a/shear_im.c b/shear_im.c new file mode 100644 index 0000000..6069b71 --- /dev/null +++ b/shear_im.c @@ -0,0 +1,11 @@ +// +build !gm + +#include +#include "shear.h" + +Image * +rotateImage(Image *image, void *data, ExceptionInfo *ex) +{ + double *d = data; + return ShearRotateImage(image, *d, ex); +} diff --git a/shear_im.go b/shear_im.go new file mode 100644 index 0000000..fcbbe8a --- /dev/null +++ b/shear_im.go @@ -0,0 +1,15 @@ +// +build !gm + +package magick + +// #include +// #include "bridge.h" +// #include "shear.h" +import "C" + +// Rotate creates a new image that is a rotated copy of an existing one. Positive angles rotate counter-clockwise (right-hand rule), while negative angles rotate clockwise. +func (im *Image) Rotate(degrees float64) (*Image, error) { + data := C.double(degrees) + return im.applyDataFunc("rotating", C.ImageDataFunc(C.rotateImage), &data) +} + \ No newline at end of file