ImageMagick / PythonMagick

PythonMagick
Other
61 stars 20 forks source link

compatibility with ImageMagick version >= 7, undefined symbols #15

Closed djorlando24 closed 4 years ago

djorlando24 commented 6 years ago

Hi all,

I tried to build PythonMagick-0.9.18 against ImageMagick 7.0.7-15 on MacOS 10.12.6 using Homebrew, building against boost 1.65.1_1 1.66.0 & boost-python 1.66.0. After successful compilation, I got a bunch of undefined symbol errors attempting to Import PythonMagick.

These errors are due to API changes in IM which are partly captured on the c++ side with some defines and don't seem to be at all captured on the Python side. Thus leading to a situation where Python tries to hook into a symbol that's either missing from _PythonMagick.so, or missing from libMagick++-7.Q16HDRI.4.dylib or libMagickCore-7.Q16HDRI.5.dylib. I've had to apply a bunch of declaration changes to several files, see below diffs. Now it works perfectly on MacOS. Not sure if this bug is related to the brew/mac version of IM, or if it is a general bug that depends on IM version.

diff --git a/../PythonMagick-master/PythonMagick/__init__.py b/./PythonMagick/__init__.py
index 6750c2e..61ba8d4 100644
--- a/../PythonMagick-master/PythonMagick/__init__.py
+++ b/./PythonMagick/__init__.py
@@ -51,10 +51,10 @@ class DrawableColor(_PythonMagick.DrawableColor):
 class DrawableCompositeImage(_PythonMagick.DrawableCompositeImage):
    pass

-class DrawableDashArray(_PythonMagick.DrawableDashArray):
+class DrawableStrokeDashArray(_PythonMagick.DrawableStrokeDashArray):
    pass

-class DrawableDashOffset(_PythonMagick.DrawableDashOffset):
+class DrawableStrokeDashOffset(_PythonMagick.DrawableStrokeDashOffset):
    pass

 class DrawableEllipse(_PythonMagick.DrawableEllipse):
@@ -78,7 +78,7 @@ class DrawableGravity(_PythonMagick.DrawableGravity):
 class DrawableLine(_PythonMagick.DrawableLine):
    pass

-class DrawableMatte(_PythonMagick.DrawableMatte):
+class DrawableAlpha(_PythonMagick.DrawableAlpha):
    pass

 class DrawableMiterLimit(_PythonMagick.DrawableMiterLimit):
@@ -174,7 +174,7 @@ class DrawableViewbox(_PythonMagick.DrawableViewbox):
 class Exception(_PythonMagick.Exception):
    pass

-class FilterTypes(_PythonMagick.FilterTypes):
+class FilterType(_PythonMagick.FilterType):
    pass

 class Geometry(_PythonMagick.Geometry):
diff --git a/../PythonMagick-master/pythonmagick_src/_Image.cpp b/./pythonmagick_src/_Image.cpp
index 8791c74..5c26cfa 100644
--- a/../PythonMagick-master/pythonmagick_src/_Image.cpp
+++ b/./pythonmagick_src/_Image.cpp
@@ -490,8 +490,8 @@ void Export_pyste_src_Image()
         .def("modifyImage", &Magick::Image::modifyImage)
 #if MagickLibVersion < 0x700
         .def("throwImageException", &Magick::Image::throwImageException)
-#endif
         .staticmethod("cacheThreshold")
+#endif
         .def( self == self )
         .def( self != self )
         .def( self > self )
diff --git a/../PythonMagick-master/pythonmagick_src/_main.cpp b/./pythonmagick_src/_main.cpp
index 449f0b1..a7d3cce 100644
--- a/../PythonMagick-master/pythonmagick_src/_main.cpp
+++ b/./pythonmagick_src/_main.cpp
@@ -30,7 +30,7 @@ void Export_pyste_src_PathArcAbs();
 void Export_pyste_src_Image();
 void Export_pyste_src_GravityType();
 void Export_pyste_src_Geometry();
-void Export_pyste_src_FilterTypes();
+void Export_pyste_src_FilterType();
 void Export_pyste_src_Exception();
 void Export_pyste_src_DrawableViewbox();
 void Export_pyste_src_DrawableTranslation();
@@ -62,7 +62,7 @@ void Export_pyste_src_DrawablePointSize();
 void Export_pyste_src_DrawablePoint();
 void Export_pyste_src_DrawablePath();
 void Export_pyste_src_DrawableMiterLimit();
-void Export_pyste_src_DrawableMatte();
+void Export_pyste_src_DrawableAlpha();
 void Export_pyste_src_DrawableLine();
 void Export_pyste_src_DrawableGravity();
 void Export_pyste_src_DrawableFont();
@@ -70,8 +70,8 @@ void Export_pyste_src_DrawableFillRule();
 void Export_pyste_src_DrawableFillOpacity();
 void Export_pyste_src_DrawableFillColor();
 void Export_pyste_src_DrawableEllipse();
-void Export_pyste_src_DrawableDashOffset();
-void Export_pyste_src_DrawableDashArray();
+void Export_pyste_src_DrawableStrokeDashOffset();
+void Export_pyste_src_DrawableStrokeDashArray();
 void Export_pyste_src_DrawableCompositeImage();
 void Export_pyste_src_DrawableColor();
 void Export_pyste_src_DrawableClipPath();
@@ -119,7 +119,7 @@ BOOST_PYTHON_MODULE(_PythonMagick)
     Export_pyste_src_Image();
     Export_pyste_src_GravityType();
     Export_pyste_src_Geometry();
-    Export_pyste_src_FilterTypes();
+    Export_pyste_src_FilterType();
     Export_pyste_src_Exception();
     Export_pyste_src_DrawableViewbox();
     Export_pyste_src_DrawableTranslation();
@@ -151,7 +151,7 @@ BOOST_PYTHON_MODULE(_PythonMagick)
     Export_pyste_src_DrawablePoint();
     Export_pyste_src_DrawablePath();
     Export_pyste_src_DrawableMiterLimit();
-    Export_pyste_src_DrawableMatte();
+    Export_pyste_src_DrawableAlpha();
     Export_pyste_src_DrawableLine();
     Export_pyste_src_DrawableGravity();
     Export_pyste_src_DrawableFont();
@@ -159,8 +159,8 @@ BOOST_PYTHON_MODULE(_PythonMagick)
     Export_pyste_src_DrawableFillOpacity();
     Export_pyste_src_DrawableFillColor();
     Export_pyste_src_DrawableEllipse();
-    Export_pyste_src_DrawableDashOffset();
-    Export_pyste_src_DrawableDashArray();
+    Export_pyste_src_DrawableStrokeDashOffset();
+    Export_pyste_src_DrawableStrokeDashArray();
     Export_pyste_src_DrawableCompositeImage();
     Export_pyste_src_DrawableColor();
     Export_pyste_src_DrawableClipPath();
urban-warrior commented 6 years ago

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick/PythonMagick later today. The patch will be available @ https://www.imagemagick.org/download/python by sometime tomorrow.

aaazalea commented 6 years ago

@urban-warrior do you know what's going on with this?