* 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
This commit is contained in:
Juri Linkov 2011-12-16 01:28:56 +02:00
parent a87ef89906
commit d1d7b339f8
2 changed files with 39 additions and 3 deletions

View 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

View 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) */