diff --git a/magick/wand/lib.lua b/magick/wand/lib.lua index 7dab75a..cce5b9e 100644 --- a/magick/wand/lib.lua +++ b/magick/wand/lib.lua @@ -116,9 +116,9 @@ get_flags = function() proc:close() return flags end +local im_7 local get_filters get_filters = function() - local fname = "magick/resample.h" local prefixes = { "/usr/include/ImageMagick", "/usr/local/include/ImageMagick", @@ -134,6 +134,17 @@ get_filters = function() } for _index_0 = 1, #prefixes do local p = prefixes[_index_0] + -- adapter im 6.9+ source install + local fname = "magick/resample.h" + do + local v = string.match(p, "%d+%.?%d*") + if v then + if tonumber(v) >= 6.9 then + fname = "MagickCore/resample.h" + im_7 = true + end + end + end local full = tostring(p) .. "/" .. tostring(fname) do local f = io.open(full) @@ -144,7 +155,13 @@ get_filters = function() f:close() content = _with_0 end - local filter_types = content:match("(typedef enum.-FilterTypes;)") + -- adapter im 6.9+ source install + local filter_types + if not (im_7) then + filter_types = content:match("(typedef enum.-FilterTypes;)") + else + filter_types = content:match("(typedef enum.-FilterType;)") + end if filter_types then ffi.cdef(filter_types) return true @@ -160,10 +177,18 @@ get_filter = function(name) end local can_resize if get_filters() then - ffi.cdef([[ MagickBooleanType MagickResizeImage(MagickWand*, - const size_t, const size_t, - const FilterTypes, const double); - ]]) + -- adapter im 6.9+ source install + if not (im_7) then + ffi.cdef([[ MagickBooleanType MagickResizeImage(MagickWand*, + const size_t, const size_t, + const FilterTypes, const double); + ]]) + else + ffi.cdef([[ MagickBooleanType MagickResizeImage(MagickWand*, + const size_t, const size_t, + const FilterType, const double); + ]]) + end can_resize = true end local try_to_load diff --git a/magick/wand/lib.moon b/magick/wand/lib.moon index 62ba6d0..027cf9c 100644 --- a/magick/wand/lib.moon +++ b/magick/wand/lib.moon @@ -111,7 +111,6 @@ ffi.cdef [[ MagickBooleanType MagickAutoOrientImage(MagickWand *wand); ]] - get_flags = -> proc = io.popen "pkg-config --cflags --libs MagickWand", "r" flags = proc\read "*a" @@ -119,8 +118,8 @@ get_flags = -> proc\close! flags +local im_7 get_filters = -> - fname = "magick/resample.h" prefixes = { "/usr/include/ImageMagick" "/usr/local/include/ImageMagick" @@ -128,10 +127,21 @@ get_filters = -> } for p in *prefixes + -- adapter im 6.9+ source install + fname = "magick/resample.h" + if v = string.match(p, "%d+%.?%d*") + if tonumber(v) >= 6.9 + fname = "MagickCore/resample.h" + im_7 = true full = "#{p}/#{fname}" if f = io.open full content = with f\read "*a" do f\close! - filter_types = content\match "(typedef enum.-FilterTypes;)" + -- adapter im 6.9+ source install + local filter_types + unless im_7 + filter_types = content\match "(typedef enum.-FilterTypes;)" + else + filter_types = content\match "(typedef enum.-FilterType;)" if filter_types ffi.cdef filter_types return true @@ -142,11 +152,19 @@ get_filter = (name) -> lib[name .. "Filter"] can_resize = if get_filters! - ffi.cdef [[ - MagickBooleanType MagickResizeImage(MagickWand*, - const size_t, const size_t, - const FilterTypes, const double); - ]] + -- adapter im 6.9+ source install + unless im_7 + ffi.cdef [[ + MagickBooleanType MagickResizeImage(MagickWand*, + const size_t, const size_t, + const FilterTypes, const double); + ]] + else + ffi.cdef [[ + MagickBooleanType MagickResizeImage(MagickWand*, + const size_t, const size_t, + const FilterType, const double); + ]] true try_to_load = (...) ->