Re: [gentoo-user] Imagemagick not being detected by emacs

2019-07-23 Thread James Stevenson
Thank you for the solution, will give it a try this evening!

James

On Tue, 23 Jul 2019, 00:06 David Haller,  wrote:

> Hello,
>
> On Sun, 21 Jul 2019, James Stevenson wrote:
> >I'm struggling to get emacs to incorporate imagemagick to allow for
> >rudimental image viewing and manipulation functionality. I have both
> >media-gfx/imagemagick-7.0.8-50 and app-editors/emacs-26.2 installed.
>
> Save the attached patch I found upstream as this commit[1] for emacs-27
>
> /etc/portage/patches/app-editors/emacs-26.2/ImageMagick-7.patch
>
> and change the emacs-26.2.ebuild (or better a copy in your local
> overlay) so that
>
> AT_M4DIR=m4 eautoreconf
>
> is run at the end of src_prepare() which is already there but
> commented out.
>
> HTH,
> -dnh
>
> [1]
> https://github.com/emacs-mirror/emacs/commit/5729486951e6a60db55ea17ee3bac9baf8b54f6a
>
>
> --
> Ok, I'm just uploading the new version of the kernel, v1.3.33, also
> known as "the buggiest kernel ever".  -- Linus Torvalds


Re: [gentoo-user] Imagemagick not being detected by emacs

2019-07-22 Thread David Haller
Hello,

On Sun, 21 Jul 2019, James Stevenson wrote:
>I'm struggling to get emacs to incorporate imagemagick to allow for
>rudimental image viewing and manipulation functionality. I have both
>media-gfx/imagemagick-7.0.8-50 and app-editors/emacs-26.2 installed.

Save the attached patch I found upstream as this commit[1] for emacs-27

/etc/portage/patches/app-editors/emacs-26.2/ImageMagick-7.patch

and change the emacs-26.2.ebuild (or better a copy in your local
overlay) so that

AT_M4DIR=m4 eautoreconf

is run at the end of src_prepare() which is already there but
commented out.

HTH,
-dnh

[1] 
https://github.com/emacs-mirror/emacs/commit/5729486951e6a60db55ea17ee3bac9baf8b54f6a


-- 
Ok, I'm just uploading the new version of the kernel, v1.3.33, also
known as "the buggiest kernel ever".  -- Linus Torvalds:100644 100644 e5d094cf9e f9bbccda0c M	configure.ac
:100644 100644 b9ff3f25c4 7e518ce34f M	src/image.c

diff --git a/configure.ac b/configure.ac
index e5d094cf9e..f9bbccda0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2518,9 +2518,16 @@ if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}"
 
 ## 6.3.5 is the earliest version known to work; see Bug#17339.
 ## 6.8.2 makes Emacs crash; see Bug#13867.
-## 7 and later have not been ported to; See Bug#25967.
-IMAGEMAGICK_MODULE="Wand >= 6.3.5 Wand != 6.8.2 Wand < 7"
-EMACS_CHECK_MODULES([IMAGEMAGICK], [$IMAGEMAGICK_MODULE])
+IMAGEMAGICK7_MODULE="MagickWand >= 7"
+IMAGEMAGICK6_MODULE="Wand >= 6.3.5 Wand != 6.8.2"
+# As we check for ImageMagick 7 then 6 track which version we find
+EMACS_CHECK_MODULES([IMAGEMAGICK], [$IMAGEMAGICK7_MODULE])
+AS_IF([test $HAVE_IMAGEMAGICK = yes],
+  [IMAGEMAGICK_MAJOR=7],
+  [
+EMACS_CHECK_MODULES([IMAGEMAGICK], [$IMAGEMAGICK6_MODULE])
+AS_IF([test $HAVE_IMAGEMAGICK = yes], [IMAGEMAGICK_MAJOR=6])
+  ])
 
 if test $HAVE_IMAGEMAGICK = yes; then
   OLD_CFLAGS=$CFLAGS
@@ -2540,6 +2547,8 @@ if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}"
 fi
 if test $HAVE_IMAGEMAGICK = yes; then
   AC_DEFINE([HAVE_IMAGEMAGICK], 1, [Define to 1 if using ImageMagick.])
+  AC_DEFINE_UNQUOTED([IMAGEMAGICK_MAJOR], [$IMAGEMAGICK_MAJOR],
+ [ImageMagick major version number (from configure).])
 else
   IMAGEMAGICK_CFLAGS=
   IMAGEMAGICK_LIBS=
@@ -5460,7 +5469,7 @@ AS_ECHO(["  Does Emacs use -lXaw3d? ${HAVE_XAW3D
   Does Emacs use -lrsvg-2?${HAVE_RSVG}
   Does Emacs use cairo?   ${HAVE_CAIRO}
   Does Emacs use -llcms2? ${HAVE_LCMS2}
-  Does Emacs use imagemagick (version 6)? ${HAVE_IMAGEMAGICK}
+  Does Emacs use imagemagick? ${HAVE_IMAGEMAGICK}
   Does Emacs support sound?   ${HAVE_SOUND}
   Does Emacs use -lgpm?   ${HAVE_GPM}
   Does Emacs use -ldbus?  ${HAVE_DBUS}
diff --git a/src/image.c b/src/image.c
index b9ff3f25c4..7e518ce34f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8273,11 +8273,20 @@ imagemagick_image_p (Lisp_Object object)
 /* The GIF library also defines DrawRectangle, but its never used in Emacs.
Therefore rename the function so it doesn't collide with ImageMagick.  */
 #define DrawRectangle DrawRectangleGif
-#include 
+
+#if IMAGEMAGICK_MAJOR == 6
+# include 
+# include 
+#else
+# include 
+# include 
+/* ImageMagick 7 compatibility definitions */
+# define PixelSetMagickColor PixelSetPixelColor
+typedef PixelInfo MagickPixelPacket;
+#endif
 
 /* ImageMagick 6.5.3 through 6.6.5 hid PixelGetMagickColor for some reason.
Emacs seems to work fine with the hidden version, so unhide it.  */
-#include 
 #if 0x653 <= MagickLibVersion && MagickLibVersion <= 0x665
 extern WandExport void PixelGetMagickColor (const PixelWand *,
 	MagickPixelPacket *);
@@ -8815,7 +8824,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
 #endif /* HAVE_MAGICKEXPORTIMAGEPIXELS */
 {
   size_t image_height;
-  MagickRealType color_scale = 65535.0 / QuantumRange;
+  MagickRealType color_scale = 65535.0 / (MagickRealType) QuantumRange;
 #ifdef USE_CAIRO
   data = xmalloc (width * height * 4);
   color_scale /= 256;


[gentoo-user] Imagemagick not being detected by emacs

2019-07-21 Thread James Stevenson
Hello all, 

I'm struggling to get emacs to incorporate imagemagick to allow for
rudimental image viewing and manipulation functionality. I have both
media-gfx/imagemagick-7.0.8-50 and app-editors/emacs-26.2 installed.
With imagemagick installed prior to an emacs rebuild the compiler output
says something to the effect of 'Imagemagick detected... no' despite the
`imagemagick` USE flag being enabled. Similarly, when I run
eval-expression in emacs for (image-type-available-p 'imagemagick), a
value of nil is returned meaning that emacs is still unaware of
imagemagick. 
I think I can probably add imagemagick to the environment path but I am
unsure which directory to add. Most of the binaries live in /usr/bin
which is already on the PATH by default. Would appreciate any
suggestions the mailing list could offer.

All the best,
James