diff --git a/magick/wand/image.lua b/magick/wand/image.lua index 21a1d19..6717af1 100644 --- a/magick/wand/image.lua +++ b/magick/wand/image.lua @@ -163,15 +163,32 @@ do } return unpack(res) end, - composite = function(self, blob, x, y, op) + composite = function(self, blob, x, y, op, clip_to_self) if op == nil then op = "OverCompositeOp" end + if clip_to_self == nil then + clip_to_self = true + end if type(blob) == "table" and blob.__class == Image then blob = blob.wand end op = assert(composite_operators:to_int(op), "invalid operator type") - return handle_result(self, lib.MagickCompositeImage(self.wand, blob, op, x, y)) + return handle_result(self, lib.MagickCompositeImage(self.wand, blob, op, clip_to_self, x, y)) + end, + composite_gravity = function(self, blob, op, gtype) + if op == nil then + op = "OverCompositeOp" + end + if gtype == nil then + gtype = "NorthWestGravity" + end + if type(blob) == "table" and blob.__class == Image then + blob = blob.wand + end + op = assert(composite_operators:to_int(op), "invalid operator type") + gtype = assert(gravity:to_int(gtype), "invalid gravity type") + return handle_result(self, lib.MagickCompositeImageGravity(self.wand, blob, op, gtype)) end, get_blob = function(self) local len = ffi.new("size_t[1]", 0) diff --git a/magick/wand/image.moon b/magick/wand/image.moon index f8fc2dd..477f0a0 100644 --- a/magick/wand/image.moon +++ b/magick/wand/image.moon @@ -129,13 +129,23 @@ class Image extends require "magick.base_image" res = { handle_result @, lib.MagickRotateImage @wand, pixel, degrees } unpack res - composite: (blob, x, y, op="OverCompositeOp") => + composite: (blob, x, y, op="OverCompositeOp", clip_to_self=true) => if type(blob) == "table" and blob.__class == Image blob = blob.wand op = assert composite_operators\to_int(op), "invalid operator type" handle_result @, - lib.MagickCompositeImage @wand, blob, op, x, y + lib.MagickCompositeImage @wand, blob, op, clip_to_self, x, y + + composite_gravity: (blob, op="OverCompositeOp", gtype="NorthWestGravity") => + if type(blob) == "table" and blob.__class == Image + blob = blob.wand + + op = assert composite_operators\to_int(op), "invalid operator type" + gtype = assert gravity\to_int(gtype), "invalid gravity type" + + handle_result @, + lib.MagickCompositeImageGravity @wand, blob, op, gtype get_blob: => len = ffi.new "size_t[1]", 0 diff --git a/magick/wand/lib.lua b/magick/wand/lib.lua index d5ab763..c163656 100644 --- a/magick/wand/lib.lua +++ b/magick/wand/lib.lua @@ -61,8 +61,13 @@ ffi.cdef([[ typedef void MagickWand; MagickBooleanType MagickCompositeImage(MagickWand *wand, const MagickWand *source_wand,const CompositeOperator compose, + const MagickBooleanType clip_to_self, const ssize_t x,const ssize_t y); + MagickBooleanType MagickCompositeImageGravity(MagickWand *wand, + const MagickWand *source_wand,const CompositeOperator compose, + const GravityType gravity); + GravityType MagickGetImageGravity(MagickWand *wand); MagickBooleanType MagickSetImageGravity(MagickWand *wand, const GravityType gravity); diff --git a/magick/wand/lib.moon b/magick/wand/lib.moon index 9f4cc48..979b74b 100644 --- a/magick/wand/lib.moon +++ b/magick/wand/lib.moon @@ -65,8 +65,13 @@ ffi.cdef [[ MagickBooleanType MagickCompositeImage(MagickWand *wand, const MagickWand *source_wand,const CompositeOperator compose, + const MagickBooleanType clip_to_self, const ssize_t x,const ssize_t y); + MagickBooleanType MagickCompositeImageGravity(MagickWand *wand, + const MagickWand *source_wand,const CompositeOperator compose, + const GravityType gravity); + GravityType MagickGetImageGravity(MagickWand *wand); MagickBooleanType MagickSetImageGravity(MagickWand *wand, const GravityType gravity);