aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov <[email protected]>2011-12-16 01:28:56 +0200
committerJuri Linkov <[email protected]>2011-12-16 01:28:56 +0200
commitd1d7b339f8d04b60ed75d337a3b4109a6cb82c98 (patch)
tree93a064c85455ec2744951da5c6ea4c46ba010b1e
parenta87ef8990608ec483657636c18b18cba7bf630c6 (diff)
* src/image.c (imagemagick_error): New function.
(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
-rw-r--r--src/ChangeLog9
-rw-r--r--src/image.c33
2 files changed, 39 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index dacce28a87..f8fa66d004 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2011-12-15 Juri Linkov <[email protected]>
+
+ * 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 <[email protected]>
* xftfont.c (xftfont_draw): Use the font metrics of s->font to
diff --git a/src/image.c b/src/image.c
index 81907d8e58..3d189a5504 100644
--- a/src/image.c
+++ b/src/image.c
@@ -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) */