We dropped ImageMagick 6 support in 0.95.9.  However, ImageMagick 6 is
still widespread (e.g., ImageMagick 7 has not been packaged in Debian
yet), and upstream plans on maintaining it until at least 2028 [1].
In this patch, we detect the version of the MagickWand library installed
on the user's system and include the appropriate header file when
building wrlib.
Note: I've only tested this with ImageMagick 6, so I'd appreciate
confirmation that it works with ImageMagick 7.
[1] 
https://github.com/ImageMagick/ImageMagick6/blob/master/NEWS.txt
---
 m4/wm_imgfmt_check.m4 | 10 +++++++---
 wrlib/load_magick.c   |  4 ++++
 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/m4/wm_imgfmt_check.m4 b/m4/wm_imgfmt_check.m4
index b5adf6f4..2236e6cc 100644
--- a/m4/wm_imgfmt_check.m4
+++ b/m4/wm_imgfmt_check.m4
@@ -313,8 +313,12 @@ AS_IF([test "x$enable_magick" = "xno"],
               dnl The library was found, check if header is available and compiles
               wm_save_CFLAGS="$CFLAGS"
               AS_IF([wm_fn_lib_try_compile "MagickWand/MagickWand.h" "MagickWand *wand;" "wand = NewMagickWand()" "$wm_cv_libchk_magick_cflags"],
-                  [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % $wm_cv_libchk_magick_libs"],
-                  [AC_MSG_ERROR([found MagickWand library but could not compile its header])])
+                  [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % $wm_cv_libchk_magick_libs"
+		   wm_cv_libchk_mgick_version=7],
+		  [wm_fn_lib_try_compile "wand/magick_wand.h" "MagickWand *wand;" "wand = NewMagickWand()" "$wm_cv_libchk_magick_cflags"],
+                  [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % $wm_cv_libchk_magick_libs"
+		   wm_cv_libchk_magick_version=6],
+		  [AC_MSG_ERROR([found MagickWand library but could not compile its header])])
               CFLAGS="$wm_save_CFLAGS"])dnl
          ])
      AS_IF([test "x$wm_cv_libchk_magick" = "xno"],
@@ -323,7 +327,7 @@ AS_IF([test "x$enable_magick" = "xno"],
          [supported_gfx="$supported_gfx Magick"
           MAGICKFLAGS=`echo "$wm_cv_libchk_magick" | sed -e 's, *%.*$,,' `
            MAGICKLIBS=`echo "$wm_cv_libchk_magick" | sed -e 's,^.*% *,,' `
-          AC_DEFINE([USE_MAGICK], [1],
+          AC_DEFINE_UNQUOTED([USE_MAGICK], [$wm_cv_libchk_magick_version],
               [defined when MagickWand library with header was found])])
      ])
 AM_CONDITIONAL([USE_MAGICK], [test "x$enable_magick" != "xno"])dnl
diff --git a/wrlib/load_magick.c b/wrlib/load_magick.c
index 1edbebc3..dbbfe92d 100644
--- a/wrlib/load_magick.c
+++ b/wrlib/load_magick.c
@@ -22,7 +22,11 @@
 
 #include "config.h"
 
+#if USE_MAGIC < 7
+#include <wand/magick_wand.h>
+#else
 #include <MagickWand/MagickWand.h>
+#endif
 
 #include "wraster.h"
 #include "imgformat.h"
-- 
2.20.1