Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extent method from ImageMagick #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions magick/wand/image.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions magick/wand/image.moon
Original file line number Diff line number Diff line change
Expand Up @@ -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}>"

Expand Down
3 changes: 3 additions & 0 deletions magick/wand/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions magick/wand/lib.moon
Original file line number Diff line number Diff line change
Expand Up @@ -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);

]]


Expand Down
6 changes: 5 additions & 1 deletion spec/magick_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec_gm/magick_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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!