From: Juri Linkov Date: Thu, 15 Dec 2011 23:28:56 +0000 (+0200) Subject: * src/image.c (imagemagick_error): New function. X-Git-Tag: emacs-pretest-24.0.93~163 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d1d7b339f8d04b60ed75d337a3b4109a6cb82c98;p=emacs.git * 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index dacce28a87d..f8fa66d0046 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2011-12-15 Juri Linkov + + * 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 * xftfont.c (xftfont_draw): Use the font metrics of s->font to diff --git a/src/image.c b/src/image.c index 81907d8e580..3d189a5504b 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) */