unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] ImageMagick Support on Windows
       [not found] <mailman.170157.1413191181.1146.emacs-diffs@gnu.org>
@ 2014-10-13  9:29 ` Eli Zaretskii
  2014-10-14 10:17   ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-13  9:29 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: emacs-devel

> From: Alexander Shukaev <haroogan@gmail.com>
> To: emacs-diffs@gnu.org
> Date: Mon, 13 Oct 2014 10:55:41 +0200
> 
> Recently I've written to another list that I would be preparing high-quality
> feature-rich 32-bit and 64-bit builds of Emacs for Windows in 2 variants:
> standalone and as MSYS2 package. Here is my first patch to allow dynamic
> linking with ImageMagick runtimes.

Thanks.

First, please send patches either to emacs-devel@gnu.org or
bug-gnu-emacs@gnu.org.  The emacs-diffs list is not normally used for
discussions, it is where the diffs from commits are sent by the VCS.

Now about your patch: in a nutshell, it misses a few more bits
necessary to get ImageMagick support in Emacs to work well on
Windows.  The missing parts are:

 . configure.ac needs changes to revert IMAGEMAGICK_LIBS to empty
   value, because otherwise src/Makefile will cause Emacs binary to be
   linked against the ImageMagick libraries, and the resulting binary
   will then refuse to start if the corresponding DLL is not available
   at run time.  You can see the example of how we do that with
   librsvg.

 . dynamic-library-alist in w32-win.el should acquire an element
   required for Emacs to know which DLL(s) to look for when
   ImageMagick support is first required.

 . If there are several ImageMagick versions out there whose DLLs are
   not binary compatible, you will need to add version checking, both
   on init_imagemagick_functions and in dynamic-library-alist,
   similarly to what we already do with some other image libraries,
   like libgif, libjpeg, etc.

Thanks again for working on this.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-13  9:29 ` [Emacs-diffs] ImageMagick Support on Windows Eli Zaretskii
@ 2014-10-14 10:17   ` Alexander Shukaev
  2014-10-14 12:16     ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-14 10:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1392 bytes --]

>
>  . configure.ac needs changes to revert IMAGEMAGICK_LIBS to empty
>    value, because otherwise src/Makefile will cause Emacs binary to be
>    linked against the ImageMagick libraries, and the resulting binary
>    will then refuse to start if the corresponding DLL is not available
>    at run time.  You can see the example of how we do that with
>    librsvg.


I'm not good at GNU Autotools stuff, sorry. Could you elaborate on this? I
don't see that "IMAGEMAGICK_LIBS" would be assigned any value in "
configure.ac". Nevertheless, on the linking stage I see:

-lMagickWand-6.Q16HDRI -lMagickCore-6.Q16HDRI

Is this what you meant? Can I just safely assign it to empty value then?

 . dynamic-library-alist in w32-win.el should acquire an element
>    required for Emacs to know which DLL(s) to look for when
>    ImageMagick support is first required.


I assume adding something like:

       '(imagemagick "libMagick++-6.Q16HDRI-5")

Is this correct?

 . If there are several ImageMagick versions out there whose DLLs are
>    not binary compatible, you will need to add version checking, both
>    on init_imagemagick_functions and in dynamic-library-alist,
>    similarly to what we already do with some other image libraries,
>    like libgif, libjpeg, etc.


Well, I have no idea about that yet. I'm not a huge expert with
ImageMagick. Perhaps somebody could clarify on that.

[-- Attachment #2: Type: text/html, Size: 2320 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 10:17   ` Alexander Shukaev
@ 2014-10-14 12:16     ` Eli Zaretskii
  2014-10-14 14:00       ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-14 12:16 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: emacs-devel

> Date: Tue, 14 Oct 2014 12:17:33 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: emacs-devel@gnu.org
> 
>     . configure.ac needs changes to revert IMAGEMAGICK_LIBS to empty
>     value, because otherwise src/Makefile will cause Emacs binary to be
>     linked against the ImageMagick libraries, and the resulting binary
>     will then refuse to start if the corresponding DLL is not available
>     at run time. You can see the example of how we do that with
>     librsvg.
> 
> I'm not good at GNU Autotools stuff, sorry. Could you elaborate on
> this?

Sure, see below.

> I don't see that "IMAGEMAGICK_LIBS" would be assigned any value in
> "configure.ac".

Here:

  HAVE_IMAGEMAGICK=no
  if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
    if test "${with_imagemagick}" != "no"; then
      ## 6.3.5 is the earliest version known to work; see Bug#17339.
      ## 6.8.2 makes Emacs crash; see Bug#13867.
      IMAGEMAGICK_MODULE="Wand >= 6.3.5 Wand != 6.8.2"
      EMACS_CHECK_MODULES([IMAGEMAGICK], [$IMAGEMAGICK_MODULE])
      AC_SUBST(IMAGEMAGICK_CFLAGS)
      AC_SUBST(IMAGEMAGICK_LIBS)  <<<<<<<<<<<<<<<<<<<<<<<<

For librsvg, we then empty the value, like this:

  ### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
  HAVE_RSVG=no
  if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
    if test "${with_rsvg}" != "no"; then
      RSVG_REQUIRED=2.11.0
      RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"

      EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
      AC_SUBST(RSVG_CFLAGS)
      AC_SUBST(RSVG_LIBS)

      if test $HAVE_RSVG = yes; then
	AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
	CFLAGS="$CFLAGS $RSVG_CFLAGS"
	# Windows loads librsvg dynamically   <<<<<<<<<<<<<<<<<<<<<<<<<<
	if test "${opsys}" = "mingw32"; then  <<<<<<<<<<<<<<<<<<<<<<<<<<
	  RSVG_LIBS=  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	fi
      fi
    fi
  fi

> Nevertheless, on the linking stage I see:
> 
> -lMagickWand-6.Q16HDRI -lMagickCore-6.Q16HDRI
> 
> Is this what you meant?

Yes.  This is what causes Emacs to be linked against the ImageMagick
libraries, so it will then require them to be present when it starts.
Try starting your Emacs with the ImageMagick DLLs renamed or moved out
of PATH, and you will see what I mean.

By contrast, if you do the same with librsvg DLLs, Emacs will start
allright, it will just refuse to show RSVG images, if and when the
user requests that.  We want the same to happen for ImageMagick.

> Can I just safely assign it to empty value then?

Yes, in configure.ac, as shown above.

>     . dynamic-library-alist in w32-win.el should acquire an element
>     required for Emacs to know which DLL(s) to look for when
>     ImageMagick support is first required.
> 
> I assume adding something like:
> 
> '(imagemagick "libMagick++-6.Q16HDRI-5")
> 
> Is this correct?

Assuming the main ImageMagick DLL is named
'libMagick++-6.Q16HDRI-5.dll', yes.  But do include the .dll extension
explicitly, like we do for other image libraries.

>     . If there are several ImageMagick versions out there whose DLLs are
>     not binary compatible, you will need to add version checking, both
>     on init_imagemagick_functions and in dynamic-library-alist,
>     similarly to what we already do with some other image libraries,
>     like libgif, libjpeg, etc.
> 
> Well, I have no idea about that yet.

Then I guess we don't need to worry about that, until someone comes
with a problem and describes it.

Thanks.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 12:16     ` Eli Zaretskii
@ 2014-10-14 14:00       ` Alexander Shukaev
  2014-10-14 15:15         ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-14 14:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

Alright, thanks for all the tips. I will prepare the patches soon. What
could be a good way to test whether ImageMagick works properly? Can you
suggest any corresponding lisp snippet to run from the top of your head?

[-- Attachment #2: Type: text/html, Size: 238 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 14:00       ` Alexander Shukaev
@ 2014-10-14 15:15         ` Eli Zaretskii
  2014-10-14 16:17           ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-14 15:15 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: emacs-devel

> Date: Tue, 14 Oct 2014 16:00:18 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: emacs-devel@gnu.org
> 
> Alright, thanks for all the tips. I will prepare the patches soon.

Thanks.

> What could be a good way to test whether ImageMagick works properly?
> Can you suggest any corresponding lisp snippet to run from the top
> of your head?

I can't, but I hope someone else here will.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 15:15         ` Eli Zaretskii
@ 2014-10-14 16:17           ` Alexander Shukaev
  2014-10-14 18:32             ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-14 16:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 27 bytes --]

Please, review. Thank you.

[-- Attachment #1.2: Type: text/html, Size: 48 bytes --]

[-- Attachment #2: configure.ac.patch --]
[-- Type: application/octet-stream, Size: 488 bytes --]

--- configure.ac.orig	2014-10-14 12:14:49.116021200 +0200
+++ configure.ac	2014-10-14 16:27:06.702869900 +0200
@@ -2291,6 +2291,11 @@
       OLD_CFLAGS=$CFLAGS
       OLD_LIBS=$LIBS
       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
+      # Windows loads libMagick dynamically
+      if test "${opsys}" = "mingw32"; then
+       	IMAGEMAGICK_LIBS=
+      fi
+
       LIBS="$IMAGEMAGICK_LIBS $LIBS"
       AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers)
       CFLAGS=$OLD_CFLAGS

[-- Attachment #3: image.c.patch --]
[-- Type: application/octet-stream, Size: 7906 bytes --]

--- src/image.c.orig	2014-10-12 11:38:49.910758000 +0200
+++ src/image.c	2014-10-12 11:37:22.011826300 +0200
@@ -7919,6 +7919,144 @@
 					    MagickPixelPacket *);
 #endif
 
+#ifdef WINDOWSNT
+
+/* ImageMagick library details.  */
+DEF_IMGLIB_FN (MagickWand *, CloneMagickWand, (const MagickWand *));
+DEF_IMGLIB_FN (MagickWand *, DestroyMagickWand, (MagickWand *));
+DEF_IMGLIB_FN (PixelIterator *, DestroyPixelIterator, (PixelIterator *));
+DEF_IMGLIB_FN (char **, GetMagickList, (const char *, size_t *, ExceptionInfo *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickCropImage, (MagickWand *, const size_t, const size_t, const ssize_t, const ssize_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickExportImagePixels, (MagickWand *, const ssize_t, const ssize_t, const size_t, const size_t, const char *, const StorageType, void *));
+DEF_IMGLIB_FN (MagickWand *, MagickFlattenImages, (MagickWand *));
+DEF_IMGLIB_FN (char *, MagickGetException, (const MagickWand *, ExceptionType *));
+DEF_IMGLIB_FN (MagickWand *, MagickGetImage, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageDelay, (MagickWand *));
+DEF_IMGLIB_FN (DisposeType, MagickGetImageDispose, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageHeight, (MagickWand *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickGetImagePage, (MagickWand *, size_t *, size_t *, ssize_t *, ssize_t *));
+DEF_IMGLIB_FN (char *, MagickGetImageSignature, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageWidth, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetNumberImages, (MagickWand *));
+DEF_IMGLIB_FN (MagickWand *, MagickMergeImageLayers, (MagickWand *, const ImageLayerMethod));
+DEF_IMGLIB_FN (MagickBooleanType, MagickReadImage, (MagickWand *, const char *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickReadImageBlob, (MagickWand *, const void *, const size_t));
+DEF_IMGLIB_FN (void *, MagickRelinquishMemory, (void *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickRotateImage, (MagickWand *, const PixelWand *, const double));
+DEF_IMGLIB_FN (MagickBooleanType, MagickScaleImage, (MagickWand *, const size_t, const size_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetFilename, (MagickWand *, const char *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetImageBackgroundColor, (MagickWand *, const PixelWand *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetIteratorIndex, (MagickWand *, const ssize_t));
+DEF_IMGLIB_FN (void, MagickWandGenesis, (void));
+DEF_IMGLIB_FN (void, MagickWandTerminus, (void));
+DEF_IMGLIB_FN (MagickWand *, NewMagickWand, (void));
+DEF_IMGLIB_FN (PixelIterator *, NewPixelIterator, (MagickWand *));
+DEF_IMGLIB_FN (PixelWand *, NewPixelWand, (void));
+DEF_IMGLIB_FN (double, PixelGetAlpha, (const PixelWand *));
+DEF_IMGLIB_FN (void, PixelGetMagickColor, (PixelWand *, MagickPixelPacket *));
+DEF_IMGLIB_FN (PixelWand **, PixelGetNextIteratorRow, (PixelIterator *, size_t *));
+DEF_IMGLIB_FN (void, PixelSetBlue, (PixelWand *, const double));
+DEF_IMGLIB_FN (void, PixelSetGreen, (PixelWand *, const double));
+DEF_IMGLIB_FN (MagickBooleanType, PixelSetIteratorRow, (PixelIterator *, const ssize_t));
+DEF_IMGLIB_FN (void, PixelSetMagickColor, (PixelWand *, const MagickPixelPacket *));
+DEF_IMGLIB_FN (void, PixelSetRed, (PixelWand *, const double));
+DEF_IMGLIB_FN (MagickBooleanType, PixelSyncIterator, (PixelIterator *));
+
+static bool
+init_imagemagick_functions (void)
+{
+  HMODULE library;
+
+  if (!(library = w32_delayed_load (Qimagemagick)))
+   return 0;
+
+  LOAD_IMGLIB_FN (library, CloneMagickWand);
+  LOAD_IMGLIB_FN (library, DestroyMagickWand);
+  LOAD_IMGLIB_FN (library, DestroyPixelIterator);
+  LOAD_IMGLIB_FN (library, GetMagickList);
+  LOAD_IMGLIB_FN (library, MagickCropImage);
+  LOAD_IMGLIB_FN (library, MagickExportImagePixels);
+  LOAD_IMGLIB_FN (library, MagickFlattenImages);
+  LOAD_IMGLIB_FN (library, MagickGetException);
+  LOAD_IMGLIB_FN (library, MagickGetImage);
+  LOAD_IMGLIB_FN (library, MagickGetImageDelay);
+  LOAD_IMGLIB_FN (library, MagickGetImageDispose);
+  LOAD_IMGLIB_FN (library, MagickGetImageHeight);
+  LOAD_IMGLIB_FN (library, MagickGetImagePage);
+  LOAD_IMGLIB_FN (library, MagickGetImageSignature);
+  LOAD_IMGLIB_FN (library, MagickGetImageWidth);
+  LOAD_IMGLIB_FN (library, MagickGetNumberImages);
+  LOAD_IMGLIB_FN (library, MagickMergeImageLayers);
+  LOAD_IMGLIB_FN (library, MagickReadImage);
+  LOAD_IMGLIB_FN (library, MagickReadImageBlob);
+  LOAD_IMGLIB_FN (library, MagickRelinquishMemory);
+  LOAD_IMGLIB_FN (library, MagickRotateImage);
+  LOAD_IMGLIB_FN (library, MagickScaleImage);
+  LOAD_IMGLIB_FN (library, MagickSetFilename);
+  LOAD_IMGLIB_FN (library, MagickSetImageBackgroundColor);
+  LOAD_IMGLIB_FN (library, MagickSetIteratorIndex);
+  LOAD_IMGLIB_FN (library, MagickWandGenesis);
+  LOAD_IMGLIB_FN (library, MagickWandTerminus);
+  LOAD_IMGLIB_FN (library, NewMagickWand);
+  LOAD_IMGLIB_FN (library, NewPixelIterator);
+  LOAD_IMGLIB_FN (library, NewPixelWand);
+  LOAD_IMGLIB_FN (library, PixelGetAlpha);
+  LOAD_IMGLIB_FN (library, PixelGetMagickColor);
+  LOAD_IMGLIB_FN (library, PixelGetNextIteratorRow);
+  LOAD_IMGLIB_FN (library, PixelSetBlue);
+  LOAD_IMGLIB_FN (library, PixelSetGreen);
+  LOAD_IMGLIB_FN (library, PixelSetIteratorRow);
+  LOAD_IMGLIB_FN (library, PixelSetMagickColor);
+  LOAD_IMGLIB_FN (library, PixelSetRed);
+  LOAD_IMGLIB_FN (library, PixelSyncIterator);
+
+  return 1;
+}
+
+#else
+
+#define fn_CloneMagickWand               CloneMagickWand
+#define fn_DestroyMagickWand             DestroyMagickWand
+#define fn_DestroyPixelIterator          DestroyPixelIterator
+#define fn_GetMagickList                 GetMagickList
+#define fn_MagickCropImage               MagickCropImage
+#define fn_MagickExportImagePixels       MagickExportImagePixels
+#define fn_MagickFlattenImages           MagickFlattenImages
+#define fn_MagickGetException            MagickGetException
+#define fn_MagickGetImage                MagickGetImage
+#define fn_MagickGetImageDelay           MagickGetImageDelay
+#define fn_MagickGetImageDispose         MagickGetImageDispose
+#define fn_MagickGetImageHeight          MagickGetImageHeight
+#define fn_MagickGetImagePage            MagickGetImagePage
+#define fn_MagickGetImageSignature       MagickGetImageSignature
+#define fn_MagickGetImageWidth           MagickGetImageWidth
+#define fn_MagickGetNumberImages         MagickGetNumberImages
+#define fn_MagickMergeImageLayers        MagickMergeImageLayers
+#define fn_MagickReadImage               MagickReadImage
+#define fn_MagickReadImageBlob           MagickReadImageBlob
+#define fn_MagickRelinquishMemory        MagickRelinquishMemory
+#define fn_MagickRotateImage             MagickRotateImage
+#define fn_MagickScaleImage              MagickScaleImage
+#define fn_MagickSetFilename             MagickSetFilename
+#define fn_MagickSetImageBackgroundColor MagickSetImageBackgroundColor
+#define fn_MagickSetIteratorIndex        MagickSetIteratorIndex
+#define fn_MagickWandGenesis             MagickWandGenesis
+#define fn_MagickWandTerminus            MagickWandTerminus
+#define fn_NewMagickWand                 NewMagickWand
+#define fn_NewPixelIterator              NewPixelIterator
+#define fn_NewPixelWand                  NewPixelWand
+#define fn_PixelGetAlpha                 PixelGetAlpha
+#define fn_PixelGetMagickColor           PixelGetMagickColor
+#define fn_PixelGetNextIteratorRow       PixelGetNextIteratorRow
+#define fn_PixelSetBlue                  PixelSetBlue
+#define fn_PixelSetGreen                 PixelSetGreen
+#define fn_PixelSetIteratorRow           PixelSetIteratorRow
+#define fn_PixelSetMagickColor           PixelSetMagickColor
+#define fn_PixelSetRed                   PixelSetRed
+#define fn_PixelSyncIterator             PixelSyncIterator
+
+#endif /* WINDOWSNT */
+
 /* Log ImageMagick error message.
    Useful when a ImageMagick function returns the status `MagickFalse'.  */
 

[-- Attachment #4: w32-win.el.patch --]
[-- Type: application/octet-stream, Size: 475 bytes --]

--- lisp/term/w32-win.el.orig	2014-10-14 12:15:29.630533700 +0200
+++ lisp/term/w32-win.el	2014-10-14 16:33:53.311610000 +0200
@@ -260,6 +260,7 @@
 	 (if (>= libgif-version 50000)
 	     '(gif "libgif-6.dll" "giflib5.dll" "gif.dll")
 	 '(gif "libgif-5.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")))
+       '(imagemagick "libMagick++-6.Q16HDRI-5.dll")
        '(svg "librsvg-2-2.dll")
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 16:17           ` Alexander Shukaev
@ 2014-10-14 18:32             ` Alexander Shukaev
  2014-10-14 21:33               ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-14 18:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 207 bytes --]

I've just realized that we forgot the fact that I need to prepend "fn_" to
every ImageMagick function invocation as well as it is done with all the
other libraries. I will amend "image.c.patch" accordingly.

[-- Attachment #2: Type: text/html, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 18:32             ` Alexander Shukaev
@ 2014-10-14 21:33               ` Alexander Shukaev
  2014-10-15  5:49                 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-14 21:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1387 bytes --]

I have amended the patches and currently they look as attached. However, I
think we have a problem here. After applying them, during the build, the
"./temacs --batch --load loadup bootstrap" command crashes when it reaches:

Loading .../src/emacs/lisp/image.el (source)...

I cannot say 100% what could be the cause of this, but I can give my 99%
that this is because some ImageMagick library has not been loaded. If you
look at one of my previous messages:

Nevertheless, on the linking stage I see:
>


-lMagickWand-6.Q16HDRI -lMagickCore-6.Q16HDRI


So these are the import libraries needed to resolve utilized ImageMagick
functions. Their respective DLLs on my system are:

libMagickWand-6.Q16HDRI-2.dll
libMagickCore-6.Q16HDRI-2.dll

It means that we should somehow add these 2 libraries as mandatory to the
"dynamic-library-alist". But from what I infer from the documentation, this:

'(imagemagick "libMagickWand-6.Q16HDRI-2.dll"
"libMagickCore-6.Q16HDRI-2.dll")

is not the correct way of doing that since this sublist, in fact,
represents alternatives to the same single library. In other words, I don't
see how certain feature can be assigned more than one mandatory DLL.

Looking forward to your thoughts on the subject. Please, review the patches
first, so that we can be sure that the problem indeed stems from what I
just described rather than something else preceding it.

[-- Attachment #1.2: Type: text/html, Size: 2223 bytes --]

[-- Attachment #2: configure.ac.patch --]
[-- Type: application/octet-stream, Size: 488 bytes --]

--- configure.ac.orig	2014-10-14 12:14:49.116021200 +0200
+++ configure.ac	2014-10-14 16:27:06.702869900 +0200
@@ -2291,6 +2291,11 @@
       OLD_CFLAGS=$CFLAGS
       OLD_LIBS=$LIBS
       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
+      # Windows loads libMagick dynamically
+      if test "${opsys}" = "mingw32"; then
+       	IMAGEMAGICK_LIBS=
+      fi
+
       LIBS="$IMAGEMAGICK_LIBS $LIBS"
       AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers)
       CFLAGS=$OLD_CFLAGS

[-- Attachment #3: image.c.patch --]
[-- Type: application/octet-stream, Size: 22474 bytes --]

--- src/image.c.orig	2014-10-14 21:40:35.406433500 +0200
+++ src/image.c	2014-10-14 21:39:50.856516900 +0200
@@ -7919,6 +7919,156 @@
 					    MagickPixelPacket *);
 #endif
 
+#ifdef WINDOWSNT
+
+/* ImageMagick library details.  */
+DEF_IMGLIB_FN (MagickWand *, CloneMagickWand, (const MagickWand *));
+DEF_IMGLIB_FN (ExceptionInfo *, DestroyExceptionInfo, (ExceptionInfo *));
+DEF_IMGLIB_FN (MagickWand *, DestroyMagickWand, (MagickWand *));
+DEF_IMGLIB_FN (PixelIterator *, DestroyPixelIterator, (PixelIterator *));
+DEF_IMGLIB_FN (PixelWand *, DestroyPixelWand, (PixelWand *));
+DEF_IMGLIB_FN (char *, DestroyString, (char *));
+DEF_IMGLIB_FN (void, GetExceptionInfo, (ExceptionInfo *));
+DEF_IMGLIB_FN (char **, GetMagickList, (const char *, size_t *, ExceptionInfo *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickCropImage, (MagickWand *, const size_t, const size_t, const ssize_t, const ssize_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickExportImagePixels, (MagickWand *, const ssize_t, const ssize_t, const size_t, const size_t, const char *, const StorageType, void *));
+DEF_IMGLIB_FN (MagickWand *, MagickFlattenImages, (MagickWand *));
+DEF_IMGLIB_FN (char *, MagickGetException, (const MagickWand *, ExceptionType *));
+DEF_IMGLIB_FN (MagickWand *, MagickGetImage, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageDelay, (MagickWand *));
+DEF_IMGLIB_FN (DisposeType, MagickGetImageDispose, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageHeight, (MagickWand *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickGetImagePage, (MagickWand *, size_t *, size_t *, ssize_t *, ssize_t *));
+DEF_IMGLIB_FN (char *, MagickGetImageSignature, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageWidth, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetNumberImages, (MagickWand *));
+DEF_IMGLIB_FN (MagickWand *, MagickMergeImageLayers, (MagickWand *, const ImageLayerMethod));
+DEF_IMGLIB_FN (MagickBooleanType, MagickReadImage, (MagickWand *, const char *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickReadImageBlob, (MagickWand *, const void *, const size_t));
+DEF_IMGLIB_FN (void *, MagickRelinquishMemory, (void *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickRotateImage, (MagickWand *, const PixelWand *, const double));
+DEF_IMGLIB_FN (MagickBooleanType, MagickScaleImage, (MagickWand *, const size_t, const size_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetFilename, (MagickWand *, const char *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetImageBackgroundColor, (MagickWand *, const PixelWand *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetIteratorIndex, (MagickWand *, const ssize_t));
+DEF_IMGLIB_FN (void, MagickWandGenesis, (void));
+DEF_IMGLIB_FN (void, MagickWandTerminus, (void));
+DEF_IMGLIB_FN (MagickWand *, NewMagickWand, (void));
+DEF_IMGLIB_FN (PixelIterator *, NewPixelIterator, (MagickWand *));
+DEF_IMGLIB_FN (PixelWand *, NewPixelWand, (void));
+DEF_IMGLIB_FN (double, PixelGetAlpha, (const PixelWand *));
+DEF_IMGLIB_FN (void, PixelGetMagickColor, (PixelWand *, MagickPixelPacket *));
+DEF_IMGLIB_FN (PixelWand **, PixelGetNextIteratorRow, (PixelIterator *, size_t *));
+DEF_IMGLIB_FN (void, PixelSetBlue, (PixelWand *, const double));
+DEF_IMGLIB_FN (void, PixelSetGreen, (PixelWand *, const double));
+DEF_IMGLIB_FN (MagickBooleanType, PixelSetIteratorRow, (PixelIterator *, const ssize_t));
+DEF_IMGLIB_FN (void, PixelSetMagickColor, (PixelWand *, const MagickPixelPacket *));
+DEF_IMGLIB_FN (void, PixelSetRed, (PixelWand *, const double));
+DEF_IMGLIB_FN (MagickBooleanType, PixelSyncIterator, (PixelIterator *));
+
+static bool
+init_imagemagick_functions (void)
+{
+  HMODULE library;
+
+  if (!(library = w32_delayed_load (Qimagemagick)))
+   return 0;
+
+  LOAD_IMGLIB_FN (library, CloneMagickWand);
+  LOAD_IMGLIB_FN (library, DestroyExceptionInfo);
+  LOAD_IMGLIB_FN (library, DestroyMagickWand);
+  LOAD_IMGLIB_FN (library, DestroyPixelIterator);
+  LOAD_IMGLIB_FN (library, DestroyPixelWand);
+  LOAD_IMGLIB_FN (library, DestroyString);
+  LOAD_IMGLIB_FN (library, GetExceptionInfo);
+  LOAD_IMGLIB_FN (library, GetMagickList);
+  LOAD_IMGLIB_FN (library, MagickCropImage);
+  LOAD_IMGLIB_FN (library, MagickExportImagePixels);
+  LOAD_IMGLIB_FN (library, MagickFlattenImages);
+  LOAD_IMGLIB_FN (library, MagickGetException);
+  LOAD_IMGLIB_FN (library, MagickGetImage);
+  LOAD_IMGLIB_FN (library, MagickGetImageDelay);
+  LOAD_IMGLIB_FN (library, MagickGetImageDispose);
+  LOAD_IMGLIB_FN (library, MagickGetImageHeight);
+  LOAD_IMGLIB_FN (library, MagickGetImagePage);
+  LOAD_IMGLIB_FN (library, MagickGetImageSignature);
+  LOAD_IMGLIB_FN (library, MagickGetImageWidth);
+  LOAD_IMGLIB_FN (library, MagickGetNumberImages);
+  LOAD_IMGLIB_FN (library, MagickMergeImageLayers);
+  LOAD_IMGLIB_FN (library, MagickReadImage);
+  LOAD_IMGLIB_FN (library, MagickReadImageBlob);
+  LOAD_IMGLIB_FN (library, MagickRelinquishMemory);
+  LOAD_IMGLIB_FN (library, MagickRotateImage);
+  LOAD_IMGLIB_FN (library, MagickScaleImage);
+  LOAD_IMGLIB_FN (library, MagickSetFilename);
+  LOAD_IMGLIB_FN (library, MagickSetImageBackgroundColor);
+  LOAD_IMGLIB_FN (library, MagickSetIteratorIndex);
+  LOAD_IMGLIB_FN (library, MagickWandGenesis);
+  LOAD_IMGLIB_FN (library, MagickWandTerminus);
+  LOAD_IMGLIB_FN (library, NewMagickWand);
+  LOAD_IMGLIB_FN (library, NewPixelIterator);
+  LOAD_IMGLIB_FN (library, NewPixelWand);
+  LOAD_IMGLIB_FN (library, PixelGetAlpha);
+  LOAD_IMGLIB_FN (library, PixelGetMagickColor);
+  LOAD_IMGLIB_FN (library, PixelGetNextIteratorRow);
+  LOAD_IMGLIB_FN (library, PixelSetBlue);
+  LOAD_IMGLIB_FN (library, PixelSetGreen);
+  LOAD_IMGLIB_FN (library, PixelSetIteratorRow);
+  LOAD_IMGLIB_FN (library, PixelSetMagickColor);
+  LOAD_IMGLIB_FN (library, PixelSetRed);
+  LOAD_IMGLIB_FN (library, PixelSyncIterator);
+
+  return 1;
+}
+
+#else
+
+#define fn_CloneMagickWand               CloneMagickWand
+#define fn_DestroyExceptionInfo          DestroyExceptionInfo
+#define fn_DestroyMagickWand             DestroyMagickWand
+#define fn_DestroyPixelIterator          DestroyPixelIterator
+#define fn_DestroyPixelWand              DestroyPixelWand
+#define fn_DestroyString                 DestroyString
+#define fn_GetExceptionInfo              GetExceptionInfo
+#define fn_GetMagickList                 GetMagickList
+#define fn_MagickCropImage               MagickCropImage
+#define fn_MagickExportImagePixels       MagickExportImagePixels
+#define fn_MagickFlattenImages           MagickFlattenImages
+#define fn_MagickGetException            MagickGetException
+#define fn_MagickGetImage                MagickGetImage
+#define fn_MagickGetImageDelay           MagickGetImageDelay
+#define fn_MagickGetImageDispose         MagickGetImageDispose
+#define fn_MagickGetImageHeight          MagickGetImageHeight
+#define fn_MagickGetImagePage            MagickGetImagePage
+#define fn_MagickGetImageSignature       MagickGetImageSignature
+#define fn_MagickGetImageWidth           MagickGetImageWidth
+#define fn_MagickGetNumberImages         MagickGetNumberImages
+#define fn_MagickMergeImageLayers        MagickMergeImageLayers
+#define fn_MagickReadImage               MagickReadImage
+#define fn_MagickReadImageBlob           MagickReadImageBlob
+#define fn_MagickRelinquishMemory        MagickRelinquishMemory
+#define fn_MagickRotateImage             MagickRotateImage
+#define fn_MagickScaleImage              MagickScaleImage
+#define fn_MagickSetFilename             MagickSetFilename
+#define fn_MagickSetImageBackgroundColor MagickSetImageBackgroundColor
+#define fn_MagickSetIteratorIndex        MagickSetIteratorIndex
+#define fn_MagickWandGenesis             MagickWandGenesis
+#define fn_MagickWandTerminus            MagickWandTerminus
+#define fn_NewMagickWand                 NewMagickWand
+#define fn_NewPixelIterator              NewPixelIterator
+#define fn_NewPixelWand                  NewPixelWand
+#define fn_PixelGetAlpha                 PixelGetAlpha
+#define fn_PixelGetMagickColor           PixelGetMagickColor
+#define fn_PixelGetNextIteratorRow       PixelGetNextIteratorRow
+#define fn_PixelSetBlue                  PixelSetBlue
+#define fn_PixelSetGreen                 PixelSetGreen
+#define fn_PixelSetIteratorRow           PixelSetIteratorRow
+#define fn_PixelSetMagickColor           PixelSetMagickColor
+#define fn_PixelSetRed                   PixelSetRed
+#define fn_PixelSyncIterator             PixelSyncIterator
+
+#endif /* WINDOWSNT */
+
 /* Log ImageMagick error message.
    Useful when a ImageMagick function returns the status `MagickFalse'.  */
 
@@ -7928,11 +8078,11 @@
   char *description;
   ExceptionType severity;
 
-  description = MagickGetException (wand, &severity);
+  description = fn_MagickGetException (wand, &severity);
   image_error ("ImageMagick error: %s",
 	       build_string (description),
 	       Qnil);
-  MagickRelinquishMemory (description);
+  fn_MagickRelinquishMemory (description);
 }
 
 /* Possibly give ImageMagick some extra help to determine the image
@@ -8011,7 +8161,7 @@
       else
 	{
 	  if (cache->wand)
-	    DestroyMagickWand (cache->wand);
+	    fn_DestroyMagickWand (cache->wand);
 	  *pcache = cache->next;
 	  xfree (cache);
 	}
@@ -8021,7 +8171,7 @@
 static struct animation_cache *
 imagemagick_get_animation_cache (MagickWand *wand)
 {
-  char *signature = MagickGetImageSignature (wand);
+  char *signature = fn_MagickGetImageSignature (wand);
   struct animation_cache *cache;
   struct animation_cache **pcache = &animation_cache;
 
@@ -8040,7 +8190,7 @@
       pcache = &cache->next;
     }
 
-  DestroyString (signature);
+  fn_DestroyString (signature);
   cache->update_time = current_timespec ();
   return cache;
 }
@@ -8053,18 +8203,18 @@
   size_t dest_width, dest_height;
   struct animation_cache *cache = imagemagick_get_animation_cache (super_wand);
 
-  MagickSetIteratorIndex (super_wand, 0);
+  fn_MagickSetIteratorIndex (super_wand, 0);
 
   if (ino == 0 || cache->wand == NULL || cache->index > ino)
     {
-      composite_wand = MagickGetImage (super_wand);
+      composite_wand = fn_MagickGetImage (super_wand);
       if (cache->wand)
-	DestroyMagickWand (cache->wand);
+	fn_DestroyMagickWand (cache->wand);
     }
   else
     composite_wand = cache->wand;
 
-  dest_height = MagickGetImageHeight (composite_wand);
+  dest_height = fn_MagickGetImageHeight (composite_wand);
 
   for (i = max (1, cache->index + 1); i <= ino; i++)
     {
@@ -8077,32 +8227,32 @@
       DisposeType dispose;
       ptrdiff_t lines = 0;
 
-      MagickSetIteratorIndex (super_wand, i);
-      sub_wand = MagickGetImage (super_wand);
+      fn_MagickSetIteratorIndex (super_wand, i);
+      sub_wand = fn_MagickGetImage (super_wand);
 
-      MagickGetImagePage (sub_wand, &source_width, &source_height,
+      fn_MagickGetImagePage (sub_wand, &source_width, &source_height,
 			  &source_left, &source_top);
 
       /* This flag says how to handle transparent pixels.  */
-      dispose = MagickGetImageDispose (sub_wand);
+      dispose = fn_MagickGetImageDispose (sub_wand);
 
-      source_iterator = NewPixelIterator (sub_wand);
+      source_iterator = fn_NewPixelIterator (sub_wand);
       if (! source_iterator)
 	{
-	  DestroyMagickWand (composite_wand);
-	  DestroyMagickWand (sub_wand);
+	  fn_DestroyMagickWand (composite_wand);
+	  fn_DestroyMagickWand (sub_wand);
 	  cache->wand = NULL;
 	  image_error ("Imagemagick pixel iterator creation failed",
 		       Qnil, Qnil);
 	  return NULL;
 	}
 
-      dest_iterator = NewPixelIterator (composite_wand);
+      dest_iterator = fn_NewPixelIterator (composite_wand);
       if (! dest_iterator)
 	{
-	  DestroyMagickWand (composite_wand);
-	  DestroyMagickWand (sub_wand);
-	  DestroyPixelIterator (source_iterator);
+	  fn_DestroyMagickWand (composite_wand);
+	  fn_DestroyMagickWand (sub_wand);
+	  fn_DestroyPixelIterator (source_iterator);
 	  cache->wand = NULL;
 	  image_error ("Imagemagick pixel iterator creation failed",
 		       Qnil, Qnil);
@@ -8113,12 +8263,12 @@
 	 iterator to where the sub-image should start. */
       if (source_top > 0)
 	{
-	  PixelSetIteratorRow (dest_iterator, source_top);
+	  fn_PixelSetIteratorRow (dest_iterator, source_top);
 	  lines = source_top;
 	}
 
-      while ((source = PixelGetNextIteratorRow (source_iterator, &source_width))
-	     != NULL)
+      while ((source = fn_PixelGetNextIteratorRow (source_iterator,
+	     &source_width)) != NULL)
 	{
 	  ptrdiff_t x;
 
@@ -8127,7 +8277,7 @@
 	  if (++lines >= dest_height)
 	    break;
 
-	  dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
+	  dest = fn_PixelGetNextIteratorRow (dest_iterator, &dest_width);
 	  for (x = 0; x < source_width; x++)
 	    {
 	      /* Sanity check.  This shouldn't happen, but apparently
@@ -8137,23 +8287,23 @@
 	      /* Normally we only copy over non-transparent pixels,
 		 but if the disposal method is "Background", then we
 		 copy over all pixels.  */
-	      if (dispose == BackgroundDispose || PixelGetAlpha (source[x]))
+	      if (dispose == BackgroundDispose || fn_PixelGetAlpha (source[x]))
 		{
-		  PixelGetMagickColor (source[x], &pixel);
-		  PixelSetMagickColor (dest[x + source_left], &pixel);
+		  fn_PixelGetMagickColor (source[x], &pixel);
+		  fn_PixelSetMagickColor (dest[x + source_left], &pixel);
 		}
 	    }
-	  PixelSyncIterator (dest_iterator);
+	  fn_PixelSyncIterator (dest_iterator);
 	}
 
-      DestroyPixelIterator (source_iterator);
-      DestroyPixelIterator (dest_iterator);
-      DestroyMagickWand (sub_wand);
+      fn_DestroyPixelIterator (source_iterator);
+      fn_DestroyPixelIterator (dest_iterator);
+      fn_DestroyMagickWand (sub_wand);
     }
 
   /* Cache a copy for the next iteration.  The current wand will be
      destroyed by the caller. */
-  cache->wand = CloneMagickWand (composite_wand);
+  cache->wand = fn_CloneMagickWand (composite_wand);
   cache->index = ino;
 
   return composite_wand;
@@ -8202,57 +8352,57 @@
      find out things about it.  */
 
   /* Initialize the imagemagick environment.  */
-  MagickWandGenesis ();
+  fn_MagickWandGenesis ();
   image = image_spec_value (img->spec, QCindex, NULL);
   ino = INTEGERP (image) ? XFASTINT (image) : 0;
-  image_wand = NewMagickWand ();
+  image_wand = fn_NewMagickWand ();
 
   if (filename)
-    status = MagickReadImage (image_wand, filename);
+    status = fn_MagickReadImage (image_wand, filename);
   else
     {
       filename_hint = imagemagick_filename_hint (img->spec, hint_buffer);
-      MagickSetFilename (image_wand, filename_hint);
-      status = MagickReadImageBlob (image_wand, contents, size);
+      fn_MagickSetFilename (image_wand, filename_hint);
+      status = fn_MagickReadImageBlob (image_wand, contents, size);
     }
 
   if (status == MagickFalse)
     {
       imagemagick_error (image_wand);
-      DestroyMagickWand (image_wand);
+      fn_DestroyMagickWand (image_wand);
       return 0;
     }
 
-  if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
+  if (ino < 0 || ino >= fn_MagickGetNumberImages (image_wand))
     {
       image_error ("Invalid image number `%s' in image `%s'",
 		   image, img->spec);
-      DestroyMagickWand (image_wand);
+      fn_DestroyMagickWand (image_wand);
       return 0;
     }
 
-  if (MagickGetImageDelay (image_wand) > 0)
+  if (fn_MagickGetImageDelay (image_wand) > 0)
     img->lisp_data =
       Fcons (Qdelay,
-             Fcons (make_float (MagickGetImageDelay (image_wand) / 100.0),
+             Fcons (make_float (fn_MagickGetImageDelay (image_wand) / 100.0),
                     img->lisp_data));
 
-  if (MagickGetNumberImages (image_wand) > 1)
+  if (fn_MagickGetNumberImages (image_wand) > 1)
     img->lisp_data =
       Fcons (Qcount,
-             Fcons (make_number (MagickGetNumberImages (image_wand)),
+             Fcons (make_number (fn_MagickGetNumberImages (image_wand)),
                     img->lisp_data));
 
   /* If we have an animated image, get the new wand based on the
      "super-wand". */
-  if (MagickGetNumberImages (image_wand) > 1)
+  if (fn_MagickGetNumberImages (image_wand) > 1)
     {
       MagickWand *super_wand = image_wand;
       image_wand = imagemagick_compute_animated_image (super_wand, ino);
       if (! image_wand)
 	image_wand = super_wand;
       else
-	DestroyMagickWand (super_wand);
+	fn_DestroyMagickWand (super_wand);
     }
 
   /* Retrieve the frame's background color, for use later.  */
@@ -8265,19 +8415,19 @@
 	|| !x_defined_color (f, SSDATA (specified_bg), &bgcolor, 0))
       x_query_frame_background_color (f, &bgcolor);
 
-    bg_wand = NewPixelWand ();
-    PixelSetRed   (bg_wand, (double) bgcolor.red   / 65535);
-    PixelSetGreen (bg_wand, (double) bgcolor.green / 65535);
-    PixelSetBlue  (bg_wand, (double) bgcolor.blue  / 65535);
+    bg_wand = fn_NewPixelWand ();
+    fn_PixelSetRed   (bg_wand, (double) bgcolor.red   / 65535);
+    fn_PixelSetGreen (bg_wand, (double) bgcolor.green / 65535);
+    fn_PixelSetBlue  (bg_wand, (double) bgcolor.blue  / 65535);
   }
 
-  compute_image_size (MagickGetImageWidth (image_wand),
-		      MagickGetImageHeight (image_wand),
+  compute_image_size (fn_MagickGetImageWidth (image_wand),
+		      fn_MagickGetImageHeight (image_wand),
 		      img->spec, &desired_width, &desired_height);
 
   if (desired_width != -1 && desired_height != -1)
     {
-      status = MagickScaleImage (image_wand, desired_width, desired_height);
+      status = fn_MagickScaleImage (image_wand, desired_width, desired_height);
       if (status == MagickFalse)
 	{
 	  image_error ("Imagemagick scale failed", Qnil, Qnil);
@@ -8310,7 +8460,7 @@
 	      if (CONSP (crop) && TYPE_RANGED_INTEGERP (ssize_t, XCAR (crop)))
 		{
 		  ssize_t crop_y = XINT (XCAR (crop));
-		  MagickCropImage (image_wand, crop_width, crop_height,
+		  fn_MagickCropImage (image_wand, crop_width, crop_height,
 				   crop_x, crop_y);
 		}
 	    }
@@ -8327,7 +8477,7 @@
   if (FLOATP (value))
     {
       rotation = extract_float (value);
-      status = MagickRotateImage (image_wand, bg_wand, rotation);
+      status = fn_MagickRotateImage (image_wand, bg_wand, rotation);
       if (status == MagickFalse)
         {
           image_error ("Imagemagick image rotate failed", Qnil, Qnil);
@@ -8342,20 +8492,20 @@
      (e.g. etc/images/splash.svg shows a white background always).  */
   {
     MagickWand *new_wand;
-    MagickSetImageBackgroundColor (image_wand, bg_wand);
+    fn_MagickSetImageBackgroundColor (image_wand, bg_wand);
 #ifdef HAVE_MAGICKMERGEIMAGELAYERS
-    new_wand = MagickMergeImageLayers (image_wand, MergeLayer);
+    new_wand = fn_MagickMergeImageLayers (image_wand, MergeLayer);
 #else
-    new_wand = MagickFlattenImages (image_wand);
+    new_wand = fn_MagickFlattenImages (image_wand);
 #endif
-    DestroyMagickWand (image_wand);
+    fn_DestroyMagickWand (image_wand);
     image_wand = new_wand;
   }
 
   /* Finally we are done manipulating the image.  Figure out the
      resulting width/height and transfer ownership to Emacs.  */
-  image_height = MagickGetImageHeight (image_wand);
-  image_width = MagickGetImageWidth (image_wand);
+  image_height = fn_MagickGetImageHeight (image_wand);
+  image_width = fn_MagickGetImageWidth (image_wand);
 
   if (! (image_width <= INT_MAX && image_height <= INT_MAX
 	 && check_image_size (f, image_width, image_height)))
@@ -8411,7 +8561,7 @@
         seems about 3 times as fast as pixel pushing(not carefully measured)
       */
       pixelwidth = CharPixel; /*??? TODO figure out*/
-      MagickExportImagePixels (image_wand, 0, 0, width, height,
+      fn_MagickExportImagePixels (image_wand, 0, 0, width, height,
 			       exportdepth, pixelwidth, ximg->data);
     }
   else
@@ -8436,7 +8586,7 @@
          images.  */
 
       /* Copy pixels from the imagemagick image structure to the x image map. */
-      iterator = NewPixelIterator (image_wand);
+      iterator = fn_NewPixelIterator (image_wand);
       if (! iterator)
         {
 #ifdef COLOR_TABLE_SUPPORT
@@ -8448,17 +8598,17 @@
           goto imagemagick_error;
         }
 
-      image_height = MagickGetImageHeight (image_wand);
+      image_height = fn_MagickGetImageHeight (image_wand);
       for (y = 0; y < image_height; y++)
         {
 	  size_t row_width;
-	  pixels = PixelGetNextIteratorRow (iterator, &row_width);
+	  pixels = fn_PixelGetNextIteratorRow (iterator, &row_width);
           if (! pixels)
             break;
 	  int xlim = min (row_width, width);
 	  for (x = 0; x < xlim; x++)
             {
-              PixelGetMagickColor (pixels[x], &pixel);
+              fn_PixelGetMagickColor (pixels[x], &pixel);
               XPutPixel (ximg, x, y,
                          lookup_rgb_color (f,
 					   color_scale * pixel.red,
@@ -8466,7 +8616,7 @@
 					   color_scale * pixel.blue));
             }
         }
-      DestroyPixelIterator (iterator);
+      fn_DestroyPixelIterator (iterator);
     }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -8482,19 +8632,19 @@
   image_put_x_image (f, img, ximg, 0);
 
   /* Final cleanup. image_wand should be the only resource left. */
-  DestroyMagickWand (image_wand);
-  if (bg_wand) DestroyPixelWand (bg_wand);
+  fn_DestroyMagickWand (image_wand);
+  if (bg_wand) fn_DestroyPixelWand (bg_wand);
 
   /* `MagickWandTerminus' terminates the imagemagick environment.  */
-  MagickWandTerminus ();
+  fn_MagickWandTerminus ();
 
   return 1;
 
  imagemagick_error:
-  DestroyMagickWand (image_wand);
-  if (bg_wand) DestroyPixelWand (bg_wand);
+  fn_DestroyMagickWand (image_wand);
+  if (bg_wand) fn_DestroyPixelWand (bg_wand);
 
-  MagickWandTerminus ();
+  fn_MagickWandTerminus ();
   /* TODO more cleanup.  */
   image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil);
   return 0;
@@ -8565,18 +8715,18 @@
   char **imtypes;
   size_t i;
 
-  GetExceptionInfo(&ex);
-  imtypes = GetMagickList ("*", &numf, &ex);
-  DestroyExceptionInfo(&ex);
+  fn_GetExceptionInfo(&ex);
+  imtypes = fn_GetMagickList ("*", &numf, &ex);
+  fn_DestroyExceptionInfo(&ex);
 
   for (i = 0; i < numf; i++)
     {
       Lisp_Object imagemagicktype = intern (imtypes[i]);
       typelist = Fcons (imagemagicktype, typelist);
-      imtypes[i] = MagickRelinquishMemory (imtypes[i]);
+      imtypes[i] = fn_MagickRelinquishMemory (imtypes[i]);
     }
 
-  MagickRelinquishMemory (imtypes);
+  fn_MagickRelinquishMemory (imtypes);
   return Fnreverse (typelist);
 }
 

[-- Attachment #4: w32-win.el.patch --]
[-- Type: application/octet-stream, Size: 477 bytes --]

--- lisp/term/w32-win.el.orig	2014-10-14 12:15:29.630533700 +0200
+++ lisp/term/w32-win.el	2014-10-14 16:33:53.311610000 +0200
@@ -260,6 +260,7 @@
 	 (if (>= libgif-version 50000)
 	     '(gif "libgif-6.dll" "giflib5.dll" "gif.dll")
 	 '(gif "libgif-5.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")))
+       '(imagemagick "libMagickWand-6.Q16HDRI-2.dll")
        '(svg "librsvg-2-2.dll")
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-14 21:33               ` Alexander Shukaev
@ 2014-10-15  5:49                 ` Eli Zaretskii
  2014-10-15  9:27                   ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-15  5:49 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: emacs-devel

> Date: Tue, 14 Oct 2014 23:33:38 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: emacs-devel@gnu.org
> 
> I have amended the patches and currently they look as attached. However, I
> think we have a problem here. After applying them, during the build, the
> "./temacs --batch --load loadup bootstrap" command crashes when it reaches:
> 
> Loading .../src/emacs/lisp/image.el (source)...
> 
> I cannot say 100% what could be the cause of this

Can you run this command under GDB, and see exactly where it crashes,
and why?

> but I can give my 99% that this is because some ImageMagick library
> has not been loaded.

I'm not sure I see where image.el needs to load image libraries.
Could you point out where you think that happens?  (Running temacs
under GDB will surely tell, btw.)  If you rename the ImageMagick DLLs
to some other names, or remove them from PATH, does the Emacs build
succeed?

> If you look at one of my previous messages:
> 
>     Nevertheless, on the linking stage I see:
>     
> 
>     -lMagickWand-6.Q16HDRI -lMagickCore-6.Q16HDRI
> 
> So these are the import libraries needed to resolve utilized ImageMagick
> functions. Their respective DLLs on my system are:
> 
> libMagickWand-6.Q16HDRI-2.dll
> libMagickCore-6.Q16HDRI-2.dll
> 
> It means that we should somehow add these 2 libraries as mandatory to the
> "dynamic-library-alist".

Is it really true that both of these DLLs need to be loaded
independently?  Isn't one of them dependent on the other?  If the
latter, just loading one DLL, the dependent one, will automatically
load the other one.  If you have the "dependency walker" utility, it
will show you the dependencies of each of these 2 DLLs.

> But from what I infer from the documentation, this:
> 
> '(imagemagick "libMagickWand-6.Q16HDRI-2.dll" "libMagickCore-6.Q16HDRI-2.dll")
> 
> is not the correct way of doing that since this sublist, in fact, represents
> alternatives to the same single library. In other words, I don't see how
> certain feature can be assigned more than one mandatory DLL.

That's right, we don't currently support more than a single
dynamically loaded library file per image type.  If it turns out (see
above) that it is impossible to fit ImageMagick into that scheme, we
will need to make additional changes, like supporting a list of DLLs
in w32-win.el and in w32_delayed_load.

But these are still speculations.  Let's first determine (1) where and
why does temacs crash, and (2) could only one of these DLLs be
loaded, and cause an automatic loading of the other.

Thanks again for working on this.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-15  5:49                 ` Eli Zaretskii
@ 2014-10-15  9:27                   ` Alexander Shukaev
  2014-10-15  9:38                     ` rzl24ozi
  2014-10-15 10:30                     ` Eli Zaretskii
  0 siblings, 2 replies; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-15  9:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]

>
> Can you run this command under GDB, and see exactly where it crashes,
> and why?


I, personally, usually don't use GDB to find out causes of crashing on
Windows, i.e. I either infer them from the code or find it out through
logging facilities. The main reason why I almost never use GDB on Windows
is the following output:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()

which actually conveys no information at all. The crash often goes deep to
some Windows system DLLs and therefore cannot be traced by GDB. This is
exactly the case this time once again. We cannot rely on GDB now...

I'm not sure I see where image.el needs to load image libraries.

Could you point out where you think that happens?  (Running temacs
> under GDB will surely tell, btw.)  If you rename the ImageMagick DLLs
> to some other names, or remove them from PATH, does the Emacs build
> succeed?


It should not necessarily load images. It can do some initialization stuff
involving ImageMagick calls. For instance, I have already found that
commenting out:

(imagemagick-register-types)

in the very bottom of "image.el" prevents the crash and "temacs.exe"
continues to function properly.

Are you sure that you have pointed out all the spots that should be patched
and that we didn't miss any of them? Please, since you know the internals
better, think of what we could miss patching, it really feels like a zero
pointer somewhere or something alike. In any case, now you know that it all
starts from the "(imagemagick-register-types)" call.

Tomorrow I'm leaving for 2 weeks vacation, so I can continue only when I'm
back. I'm still available today for discussions.

[-- Attachment #2: Type: text/html, Size: 2595 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-15  9:27                   ` Alexander Shukaev
@ 2014-10-15  9:38                     ` rzl24ozi
  2014-10-15 10:35                       ` Eli Zaretskii
  2014-10-15 10:30                     ` Eli Zaretskii
  1 sibling, 1 reply; 15+ messages in thread
From: rzl24ozi @ 2014-10-15  9:38 UTC (permalink / raw)
  To: Alexander Shukaev, Eli Zaretskii; +Cc: emacs-devel

I have created imagemagick support patch on Windows for pretest
24.3.94, and using it. I'm testing it by viewing BMP and other
supported image by imagemagick, and it seems to work well.

My patch is here.

https://gist.github.com/rzl24ozi/d588b40217b80e3dae65

I hope this patch help you.

Eli Zaretskii <eliz@gnu.org> writes:
> But these are still speculations.  Let's first determine (1) where and
> why does temacs crash, and (2) could only one of these DLLs be
> loaded, and cause an automatic loading of the other.

(1)
In my case, crashed at imagemagick-types in image.c.
imagemagick-register-types is called in image.el and finally
imagemagick-types in image.c is called, but at this time, imagemagick
functions are not initialized yet. then temacs crash.

I add init_imagemagick_functons to imagemagick-types.

And, for imagemagick-register-types to work well, there was a need to
load image.el after w32-win.el in loadup.el because
dynamic-library-alist is set in w32-win.el.

(2)
Yes, libMagickWand-XXX.dll depend on libMagickCore-XXX.dll and
libMagickCore-XXX.dll is automatically loaded when load
libMagickWand-XXX.dll.
But some functions used in image.c is in libMagickCore-XXX.dll.
To get these functions by GetProcAddress, need to load
libMagickCore-XXX.dll separately.

Although is not a smart way, I add two DLLs as below
to dynamic-library-alist and load each library separately.
(My imagemagick is built without --enable-hdri.)

'(magickwand "libMagickWand-6.Q16-2.dll")
'(magickcore "libMagickCore-6.Q16-2.dll")



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-15  9:27                   ` Alexander Shukaev
  2014-10-15  9:38                     ` rzl24ozi
@ 2014-10-15 10:30                     ` Eli Zaretskii
  1 sibling, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-15 10:30 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: emacs-devel

> Date: Wed, 15 Oct 2014 11:27:36 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: emacs-devel@gnu.org
> 
>     Can you run this command under GDB, and see exactly where it crashes,
>     and why?
> 
> I, personally, usually don't use GDB to find out causes of crashing on Windows,
> i.e. I either infer them from the code or find it out through logging
> facilities. The main reason why I almost never use GDB on Windows is the
> following output:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000000000 in ?? ()
> 
> which actually conveys no information at all. The crash often goes deep to some
> Windows system DLLs and therefore cannot be traced by GDB. This is exactly the
> case this time once again. We cannot rely on GDB now...

If you are sure the above was from thread #1, then there's only one
explanation: Emacs tried to call a function whose address was not yet
set by call GetProcAddress.

> Are you sure that you have pointed out all the spots that should be patched and
> that we didn't miss any of them? Please, since you know the internals better,
> think of what we could miss patching, it really feels like a zero pointer
> somewhere or something alike. In any case, now you know that it all starts from
> the "(imagemagick-register-types)" call.

I see someone else posted an explanation for the crash, so I think you
have a starting point.

Thanks.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-15  9:38                     ` rzl24ozi
@ 2014-10-15 10:35                       ` Eli Zaretskii
  2014-10-15 12:02                         ` Alexander Shukaev
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-15 10:35 UTC (permalink / raw)
  To: rzl24ozi; +Cc: haroogan, emacs-devel

> From: rzl24ozi@gmail.com
> Cc: emacs-devel@gnu.org
> Date: Wed, 15 Oct 2014 18:38:30 +0900
> 
> In my case, crashed at imagemagick-types in image.c.
> imagemagick-register-types is called in image.el and finally
> imagemagick-types in image.c is called, but at this time, imagemagick
> functions are not initialized yet. then temacs crash.
> 
> I add init_imagemagick_functons to imagemagick-types.

I think that's the right fix, thanks.

> And, for imagemagick-register-types to work well, there was a need to
> load image.el after w32-win.el in loadup.el because
> dynamic-library-alist is set in w32-win.el.

That's probably correct as well.

> Yes, libMagickWand-XXX.dll depend on libMagickCore-XXX.dll and
> libMagickCore-XXX.dll is automatically loaded when load
> libMagickWand-XXX.dll.
> But some functions used in image.c is in libMagickCore-XXX.dll.
> To get these functions by GetProcAddress, need to load
> libMagickCore-XXX.dll separately.
> 
> Although is not a smart way, I add two DLLs as below
> to dynamic-library-alist and load each library separately.
> (My imagemagick is built without --enable-hdri.)
> 
> '(magickwand "libMagickWand-6.Q16-2.dll")
> '(magickcore "libMagickCore-6.Q16-2.dll")

Yuck!  I think it's much better to teach w32-win.el and
w32_delayed_load to load more than one library for a certain image
type.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-15 10:35                       ` Eli Zaretskii
@ 2014-10-15 12:02                         ` Alexander Shukaev
  2014-10-15 12:36                           ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Shukaev @ 2014-10-15 12:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rzl24ozi, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

>
> Yuck!  I think it's much better to teach w32-win.el and
> w32_delayed_load to load more than one library for a certain image
> type.
>

Note that although such modification would be reasonable, still

'(magickwand "libMagickWand-6.Q16-2.dll")
'(magickcore "libMagickCore-6.Q16-2.dll")

is consistent with what you already have for RSVG:

'(svg "librsvg-2-2.dll")
'(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
'(glib "libglib-2.0-0.dll")
'(gobject "libgobject-2.0-0.dll")

[-- Attachment #2: Type: text/html, Size: 1285 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Emacs-diffs] ImageMagick Support on Windows
  2014-10-15 12:02                         ` Alexander Shukaev
@ 2014-10-15 12:36                           ` Eli Zaretskii
  0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2014-10-15 12:36 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: rzl24ozi, emacs-devel

> Date: Wed, 15 Oct 2014 14:02:20 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: rzl24ozi@gmail.com, emacs-devel@gnu.org
> 
>     Yuck! I think it's much better to teach w32-win.el and
>     w32_delayed_load to load more than one library for a certain image
>     type.
>     
> 
> Note that although such modification would be reasonable, still
> 
> '(magickwand "libMagickWand-6.Q16-2.dll")
> '(magickcore "libMagickCore-6.Q16-2.dll")
> 
> is consistent with what you already have for RSVG:
> 
> '(svg "librsvg-2-2.dll")
> '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
> '(glib "libglib-2.0-0.dll")
> '(gobject "libgobject-2.0-0.dll")

Right, I forgot.

So I guess it would be fine to repeat the same stanza.



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-10-15 12:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.170157.1413191181.1146.emacs-diffs@gnu.org>
2014-10-13  9:29 ` [Emacs-diffs] ImageMagick Support on Windows Eli Zaretskii
2014-10-14 10:17   ` Alexander Shukaev
2014-10-14 12:16     ` Eli Zaretskii
2014-10-14 14:00       ` Alexander Shukaev
2014-10-14 15:15         ` Eli Zaretskii
2014-10-14 16:17           ` Alexander Shukaev
2014-10-14 18:32             ` Alexander Shukaev
2014-10-14 21:33               ` Alexander Shukaev
2014-10-15  5:49                 ` Eli Zaretskii
2014-10-15  9:27                   ` Alexander Shukaev
2014-10-15  9:38                     ` rzl24ozi
2014-10-15 10:35                       ` Eli Zaretskii
2014-10-15 12:02                         ` Alexander Shukaev
2014-10-15 12:36                           ` Eli Zaretskii
2014-10-15 10:30                     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).