unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: Fallback mode for image magick?
Date: Tue, 2 Jul 2013 00:00:52 +0200	[thread overview]
Message-ID: <CANtbJLGykpw=Xpi=BJnqn4L0EUUHobU7f7ZsC8TYQgwVX6jDdQ@mail.gmail.com> (raw)
In-Reply-To: <m34ncio26n.fsf@stories.gnus.org>


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

2013/6/28 Lars Magne Ingebrigtsen <larsi@gnus.org>

> Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com> writes:
>
> > My intent however is to write a fix, that makes this a default
> > fallback for code that wants to use builtin support without the need
> > to edit the third party source code. Finding out what functions and
> > variables I need to emulate is the hard part here for me.
>
> If you could implement native ImageMagick support for Emacs under
> Microsoft Windows, that would probably be even better.  :-)
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>   bloggy blog http://lars.ingebrigtsen.no/
>

So, I got it to compile by adding DEF_IMGLIB_FN and LOAD_IMGLIB_FN entries
like for the other types, following the hint from an older discussion [1]
and correcting it. For reference I have attached the patches to
nt/configure.bat and src/image.c.

Sadly however, I now can't get the MinGW bundle of ImageMagick working.

convert.exe: UnableToOpenModuleFile
> `C:\Users\klaus\.magick\IM_MOD_RL_PNG_.dll': No such file or directory @
> warning/module.c/GetMagickModulePath/812.


While the function `imagemagick-types` is now defined in the session, still
no resizing occurs, probably because ImageMagick silently fails.

Also in this configuration JPEG is not included in `(imagemagick-types)`
for some reason.

Apparently the official ImageMagick version for Windows is tightly bound to
Visual Studio, which doesn't help the case either.

Honestly, the fallback-solution gets more and more attractive ;)


[1] http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01585.html

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

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

--- image.c.orig	2013-07-01 10:21:08.404397000 +0200
+++ image.c	2013-07-01 18:52:44.323104200 +0200
@@ -8236,6 +8236,72 @@
   return Fnreverse (typelist);
 }
 
+#if defined HAVE_NTGUI && defined WINDOWSNT
+
+DEF_IMGLIB_FN (void, MagickWandGenesis, (void));
+DEF_IMGLIB_FN (char** , GetMagickList, ( const char *, unsigned long *));
+DEF_IMGLIB_FN (MagickWand*, NewMagickWand, (void));
+DEF_IMGLIB_FN (MagickBooleanType, MagickSetResolution, (MagickWand *, const double, const double));
+DEF_IMGLIB_FN (MagickBooleanType, MagickPingImage, (MagickWand *, const char *));
+DEF_IMGLIB_FN (size_t, MagickGetNumberImages, (MagickWand *));
+DEF_IMGLIB_FN (MagickWand *, DestroyMagicWand, (MagickWand *));
+DEF_IMGLIB_FN (ImageInfo *, CloneImageInfo, (const ImageInfo *));
+DEF_IMGLIB_FN (ExceptionInfo *, AcquireExceptionInfo, (void));
+DEF_IMGLIB_FN (Image *, ReadImage, (const ImageInfo *, ExceptionInfo *));
+DEF_IMGLIB_FN (void, CatchException, (ExceptionInfo *));
+DEF_IMGLIB_FN (MagickWand *, NewMagickWandFromImage, (const Image *));
+DEF_IMGLIB_FN (size_t, MagickGetImageHeight, (MagickWand *));
+DEF_IMGLIB_FN (size_t, MagickGetImageWidth, (MagickWand *));
+DEF_IMGLIB_FN (MagickBooleanType, MagickScaleImage, (MagickWand *,const size_t,const size_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickPingImageBlob, (MagickWand *,const void *,const size_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickReadImageBlob, (MagickWand *, const void *, const size_t));
+DEF_IMGLIB_FN (PixelWand*, NewPixelWand, (void));
+DEF_IMGLIB_FN (void, PixelSetColor, (PixelWand *,const size_t));
+DEF_IMGLIB_FN (MagickBooleanType, MagickRotateImage, (MagickWand *,const PixelWand *,const double));
+DEF_IMGLIB_FN (MagickBooleanType, MagickCropImage, (MagickWand *,const size_t,const size_t,const ssize_t, const ssize_t));
+DEF_IMGLIB_FN (PixelIterator*, NewPixelIterator, (MagickWand*));
+DEF_IMGLIB_FN (void, PixelGetMagickColor, (const PixelWand *,MagickPixelPacket *));
+DEF_IMGLIB_FN (PixelIterator*, DestroyPixelIterator,(PixelIterator *iterator));
+
+static bool 
+init_imagemagick_functions (void)
+{
+  HMODULE library;
+
+  /* Try loading ImageMagick library under probable names.  */
+  if (!(library = w32_delayed_load (Qimagemagick)))
+    return 0;
+
+  LOAD_IMGLIB_FN (library, MagickWandGenesis);
+  LOAD_IMGLIB_FN (library, GetMagickList);
+  LOAD_IMGLIB_FN (library, NewMagickWand);
+  LOAD_IMGLIB_FN (library, MagickSetResolution);
+  LOAD_IMGLIB_FN (library, MagickPingImage);
+  LOAD_IMGLIB_FN (library, MagickGetNumberImages);
+  LOAD_IMGLIB_FN (library, DestroyMagicWand);
+  LOAD_IMGLIB_FN (library, CloneImageInfo);
+  LOAD_IMGLIB_FN (library, AcquireExceptionInfo);
+  LOAD_IMGLIB_FN (library, ReadImage);
+  LOAD_IMGLIB_FN (library, CatchException);
+  LOAD_IMGLIB_FN (library, NewMagickWandFromImage);
+  LOAD_IMGLIB_FN (library, MagickGetImageHeight);
+  LOAD_IMGLIB_FN (library, MagickGetImageWidth);
+  LOAD_IMGLIB_FN (library, MagickScaleImage);
+  LOAD_IMGLIB_FN (library, MagickPingImageBlob);
+  LOAD_IMGLIB_FN (library, MagickReadImageBlob);
+  LOAD_IMGLIB_FN (library, NewPixelWand);
+  LOAD_IMGLIB_FN (library, PixelSetColor);
+  LOAD_IMGLIB_FN (library, MagickRotateImage);
+  LOAD_IMGLIB_FN (library, MagickCropImage);
+  LOAD_IMGLIB_FN (library, NewPixelIterator);
+  LOAD_IMGLIB_FN (library, PixelGetMagickColor);
+  LOAD_IMGLIB_FN (library, DestroyPixelIterator);
+
+  return 1;
+}
+
+#endif /* defined HAVE_NTGUI && defined WINDOWSNT  */
+
 #endif	/* defined (HAVE_IMAGEMAGICK) */
 
 

[-- Attachment #3: configure.bat.patch --]
[-- Type: application/octet-stream, Size: 3966 bytes --]

--- configure.bat.orig	2013-07-01 10:21:08.404397000 +0200
+++ configure.bat	2013-07-01 15:40:15.038522900 +0200
@@ -133,6 +133,7 @@
 if "%1" == "--without-gnutls" goto withoutgnutls
 if "%1" == "--without-libxml2" goto withoutlibxml2
 if "%1" == "--without-xpm" goto withoutxpm
+if "%1" == "--without-imagemagick" goto withoutimagemagick
 if "%1" == "--with-svg" goto withsvg
 if "%1" == "--distfiles" goto distfiles
 if "%1" == "" goto checkutils
@@ -158,6 +159,7 @@
 echo.   --without-xpm           do not use XPM library even if it is installed
 echo.   --without-gnutls        do not use GnuTLS library even if it is installed
 echo.   --without-libxml2       do not use libxml2 library even if it is installed
+echo.   --without-imagemagick   do not use ImageMagick library even if it is installed
 echo.   --with-svg              use the RSVG library (experimental)
 echo.   --distfiles             path to files for make dist, e.g. libXpm.dll
 if "%use_extensions%" == "0" goto end
@@ -353,6 +355,14 @@
 
 rem ----------------------------------------------------------------------
 
+:withoutimagemagick
+set imagemagicksupport=N
+set HAVE_IMAGEMAGICK=
+shift 
+goto again 
+
+rem ----------------------------------------------------------------------
+
 :distfiles
 set HAVE_DISTFILES=1
 shift
@@ -722,6 +732,31 @@
 set HAVE_RSVG=1
 
 :svgDone
+
+if (%imagemagicksupport%) == (N) goto imagemagickDone
+
+echo Checking for ImageMagick...
+echo #define FOR_MSW 1 >junk.c
+echo #define MAGICKCORE_QUANTUM_DEPTH 16 >>junk.c
+echo #define MAGICKCORE_HDRI_ENABLE 0 >>junk.c
+echo #include "wand/MagickWand.h" >>junk.c
+echo main (){} >>junk.c
+rem   -o option is ignored with cl, but allows result to be consistent.
+echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
+%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
+if exist junk.obj goto haveImagemagick
+
+echo ...wand/MagickWand.h not found, building without ImageMagick support.
+echo The failed program was: >>config.log
+type junk.c >>config.log
+set HAVE_IMAGEMAGICK=
+goto :imagemagickDone
+
+:haveImageMagick
+echo ...ImageMagick header available, building with ImageMagick support.
+set HAVE_IMAGEMAGICK=1
+
+:imagemagickDone
 rm -f junk.c junk.obj junk.err junk.out
 
 rem Any distfiles provided for building distribution? If no, we're done.
@@ -809,6 +844,7 @@
 if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp
 if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp
 if not "(%HAVE_XPM%)" == "()" echo #define HAVE_XPM 1 >>config.tmp
+if not "(%HAVE_IMAGEMAGICK%)" == "()" echo #define HAVE_IMAGEMAGICK 1 >>config.tmp
 if "(%HAVE_RSVG%)" == "(1)" echo #define HAVE_RSVG 1 >>config.tmp
 
 echo /* End of settings from configure.bat.  */ >>config.tmp
@@ -893,12 +929,19 @@
  echo   Install libtiff development files or use --without-tiff
 
 :checkgif
-if not "(%HAVE_GIF%)" == "()" goto checkdistfiles
-if (%gifsupport%) == (N) goto checkdistfiles
+if not "(%HAVE_GIF%)" == "()" goto checkimagemagick
+if (%gifsupport%) == (N) goto checkimagemagick
  set libsOK=0
  echo GIF support is missing.
  echo   Install giflib or libungif development files or use --without-gif
 
+:checkimagemagick
+if not "(%HAVE_IMAGEMAGICK%)" == "()" goto checkdistfiles
+if (%imagemagicksupport%) == (N) goto checkdistfiles
+ set libsOK=0
+ echo ImageMagick support is missing.
+ echo   Install ImageMagick development files or use --without-imagemagick
+
 :checkdistfiles
 if "(%HAVE_DISTFILES%)" == "()" goto donelibchecks
 if (%distFilesOk%) == (1) goto donelibchecks
@@ -950,12 +993,14 @@
 set tiffsupport=
 set xpmsupport=
 set svgsupport=
+set imagemagicksupport=
 set libsOK=
 set HAVE_GIF=
 set HAVE_JPEG=
 set HAVE_PNG=
 set HAVE_TIFF=
 set HAVE_XPM=
+set HAVE_IMAGEMAGICK=
 set dbginfo=
 endlocal
 set use_extensions=

  reply	other threads:[~2013-07-01 22:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27 14:05 Fallback mode for image magick? Klaus-Dieter Bauer
2013-06-27 15:35 ` Lars Magne Ingebrigtsen
2013-06-27 16:17   ` Glenn Morris
2013-06-27 16:29   ` Klaus-Dieter Bauer
2013-06-27 17:34   ` Eli Zaretskii
2013-06-27 17:00 ` Glenn Morris
2013-06-28 12:15   ` Klaus-Dieter Bauer
2013-06-28 12:22     ` Lars Magne Ingebrigtsen
2013-07-01 22:00       ` Klaus-Dieter Bauer [this message]
2013-07-02 22:12         ` Klaus-Dieter Bauer
2013-07-06 15:31           ` Lars Ingebrigtsen
2013-07-06 15:52             ` Eli Zaretskii
2013-07-06 15:59               ` Lars Ingebrigtsen
2013-07-06 16:04                 ` Eli Zaretskii
2013-07-07  9:22                 ` Klaus-Dieter Bauer
2013-07-06 17:10               ` Glenn Morris
2013-07-07  9:28               ` Klaus-Dieter Bauer
2013-07-07 15:59                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANtbJLGykpw=Xpi=BJnqn4L0EUUHobU7f7ZsC8TYQgwVX6jDdQ@mail.gmail.com' \
    --to=bauer.klaus.dieter@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).