]> git.eshelyaron.com Git - emacs.git/commitdiff
* src/image.c (imagemagick_error): New function.
authorJuri Linkov <juri@jurta.org>
Thu, 15 Dec 2011 23:28:56 +0000 (01:28 +0200)
committerJuri Linkov <juri@jurta.org>
Thu, 15 Dec 2011 23:28:56 +0000 (01:28 +0200)
(imagemagick_load_image): Comment out `MagickSetResolution' call.
Use `imagemagick_error' where ImageMagick functions return
`MagickFalse'.
(Fimagemagick_types): Add `Fnreverse' to return the list in the
proper order.

Fixes: debbugs:10112
src/ChangeLog
src/image.c

index dacce28a87df9a5c781aea398555c9a6cb8fa81b..f8fa66d00465ce3eedb8938f7b11cfe3ac628a43 100644 (file)
@@ -1,3 +1,12 @@
+2011-12-15  Juri Linkov  <juri@jurta.org>
+
+       * image.c (imagemagick_error): New function.  (Bug#10112)
+       (imagemagick_load_image): Comment out `MagickSetResolution' call.
+       Use `imagemagick_error' where ImageMagick functions return
+       `MagickFalse'.
+       (Fimagemagick_types): Add `Fnreverse' to return the list in the
+       proper order.
+
 2011-12-15  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * xftfont.c (xftfont_draw): Use the font metrics of s->font to
index 81907d8e580ea4938975bca29bb4752c72d24226..3d189a5504b12a68c98cba96d36f4b6ac4e4c52f 100644 (file)
@@ -7564,6 +7564,22 @@ extern WandExport void PixelGetMagickColor (const PixelWand *,
                                            MagickPixelPacket *);
 #endif
 
+/* Log ImageMagick error message.
+   Useful when a ImageMagick function returns the status `MagickFalse'.  */
+
+static void
+imagemagick_error (MagickWand *wand)
+{
+  char *description;
+  ExceptionType severity;
+
+  description = MagickGetException (wand, &severity);
+  image_error ("ImageMagick error: %s",
+              make_string (description, strlen (description)),
+              Qnil);
+  description = (char *) MagickRelinquishMemory (description);
+}
+
 /* Helper function for imagemagick_load, which does the actual loading
    given contents and size, apart from frame and image structures,
    passed from imagemagick_load.  Uses librimagemagick to do most of
@@ -7618,6 +7634,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
   image = image_spec_value (img->spec, QCindex, NULL);
   ino = INTEGERP (image) ? XFASTINT (image) : 0;
   ping_wand = NewMagickWand ();
+  /* MagickSetResolution (ping_wand, 2, 2);   (Bug#10112)  */
 
   if (filename != NULL)
     {
@@ -7628,7 +7645,12 @@ imagemagick_load_image (struct frame *f, struct image *img,
       status = MagickPingImageBlob (ping_wand, contents, size);
     }
 
-  MagickSetResolution (ping_wand, 2, 2);
+  if (status == MagickFalse)
+    {
+      imagemagick_error (ping_wand);
+      DestroyMagickWand (ping_wand);
+      return 0;
+    }
 
   if (! (0 <= ino && ino < MagickGetNumberImages (ping_wand)))
     {
@@ -7669,7 +7691,10 @@ imagemagick_load_image (struct frame *f, struct image *img,
     {
       image_wand = NewMagickWand ();
       if (MagickReadImageBlob (image_wand, contents, size) == MagickFalse)
-       goto imagemagick_error;
+       {
+         imagemagick_error (image_wand);
+         goto imagemagick_error;
+       }
     }
 
   /* If width and/or height is set in the display spec assume we want
@@ -7697,6 +7722,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
       if (status == MagickFalse)
        {
          image_error ("Imagemagick scale failed", Qnil, Qnil);
+         imagemagick_error (image_wand);
          goto imagemagick_error;
        }
     }
@@ -7751,6 +7777,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
       if (status == MagickFalse)
         {
           image_error ("Imagemagick image rotate failed", Qnil, Qnil);
+         imagemagick_error (image_wand);
           goto imagemagick_error;
         }
     }
@@ -7975,7 +8002,7 @@ recognize as images, such as C.  See `imagemagick-types-inhibit'.  */)
       Qimagemagicktype = intern (imtypes[i]);
       typelist = Fcons (Qimagemagicktype, typelist);
     }
-  return typelist;
+  return Fnreverse (typelist);
 }
 
 #endif /* defined (HAVE_IMAGEMAGICK) */