diff --git a/magick/wand/image.lua b/magick/wand/image.lua index 21a1d19..e7d5a2b 100644 --- a/magick/wand/image.lua +++ b/magick/wand/image.lua @@ -244,6 +244,9 @@ do reset_page = function(self) return handle_result(self, lib.MagickResetImagePage(self.wand, nil)) end, + extent = function(self, w, h, x, y) + return handle_result(self, lib.MagickExtentImage(self.wand, w, h, x, y)) + end, __tostring = function(self) return "Image<" .. tostring(self.path) .. ", " .. tostring(self.wand) .. ">" end diff --git a/magick/wand/image.moon b/magick/wand/image.moon index f8fc2dd..32a3470 100644 --- a/magick/wand/image.moon +++ b/magick/wand/image.moon @@ -208,6 +208,10 @@ class Image extends require "magick.base_image" reset_page: => handle_result @, lib.MagickResetImagePage @wand, nil + extent: (w, h, x, y) => + handle_result @, + lib.MagickExtentImage @wand, w, h, x, y + __tostring: => "Image<#{@path}, #{@wand}>" diff --git a/magick/wand/lib.lua b/magick/wand/lib.lua index d5ab763..8bf9fa1 100644 --- a/magick/wand/lib.lua +++ b/magick/wand/lib.lua @@ -114,6 +114,9 @@ ffi.cdef([[ typedef void MagickWand; MagickBooleanType MagickSetImageDepth(MagickWand *,const unsigned long); unsigned long MagickGetImageDepth(MagickWand *); + MagickBooleanType MagickExtentImage(MagickWand *wand,const size_t width, + const size_t height,const ssize_t x,const ssize_t y); + ]]) local get_flags get_flags = function() diff --git a/magick/wand/lib.moon b/magick/wand/lib.moon index 9f4cc48..0641a43 100644 --- a/magick/wand/lib.moon +++ b/magick/wand/lib.moon @@ -118,6 +118,9 @@ ffi.cdef [[ MagickBooleanType MagickSetImageDepth(MagickWand *,const unsigned long); unsigned long MagickGetImageDepth(MagickWand *); + MagickBooleanType MagickExtentImage(MagickWand *wand,const size_t width, + const size_t height,const ssize_t x,const ssize_t y); + ]] diff --git a/spec/magick_spec.moon b/spec/magick_spec.moon index b0ede8e..6506f51 100644 --- a/spec/magick_spec.moon +++ b/spec/magick_spec.moon @@ -98,7 +98,6 @@ describe "magick", -> assert img\write out_path "composite.png" it "modulate", -> - img2 = img\clone! assert img\modulate 50, 50, 50 assert img\write out_path "modulate.png" @@ -168,6 +167,11 @@ describe "magick", -> img2 = img\clone! img2\set_depth 16 + it "extents", -> + img2 = img\clone! + assert img2\extent 200, 300, 0, 0 + assert.same 200, img2\get_width! + assert.same 300, img2\get_height! describe "color_image", -> import load_image from magick diff --git a/spec_gm/magick_spec.moon b/spec_gm/magick_spec.moon index 75be5d1..69abfca 100644 --- a/spec_gm/magick_spec.moon +++ b/spec_gm/magick_spec.moon @@ -72,7 +72,6 @@ describe "magick", -> assert img\write out_path "composite.png" it "modulate", -> - img2 = img\clone! assert img\modulate 50, 50, 50 assert img\write out_path "modulate.png" @@ -98,4 +97,9 @@ describe "magick", -> img2 = img\clone! img2\set_depth 16 + it "extents", -> + img2 = img\clone! + assert img2\extent 200, 300, 0, 0 + assert.same 200, img2\get_width! + assert.same 300, img2\get_height!