aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorJuri Linkov2011-12-16 01:28:56 +0200
committerJuri Linkov2011-12-16 01:28:56 +0200
commitd1d7b339f8d04b60ed75d337a3b4109a6cb82c98 (patch)
tree93a064c85455ec2744951da5c6ea4c46ba010b1e /src/image.c
parenta87ef8990608ec483657636c18b18cba7bf630c6 (diff)
downloademacs-d1d7b339f8d04b60ed75d337a3b4109a6cb82c98.tar.gz
emacs-d1d7b339f8d04b60ed75d337a3b4109a6cb82c98.zip
* 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
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c33
1 files changed, 30 insertions, 3 deletions
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 *,
7564 MagickPixelPacket *); 7564 MagickPixelPacket *);
7565#endif 7565#endif
7566 7566
7567/* Log ImageMagick error message.
7568 Useful when a ImageMagick function returns the status `MagickFalse'. */
7569
7570static void
7571imagemagick_error (MagickWand *wand)
7572{
7573 char *description;
7574 ExceptionType severity;
7575
7576 description = MagickGetException (wand, &severity);
7577 image_error ("ImageMagick error: %s",
7578 make_string (description, strlen (description)),
7579 Qnil);
7580 description = (char *) MagickRelinquishMemory (description);
7581}
7582
7567/* Helper function for imagemagick_load, which does the actual loading 7583/* Helper function for imagemagick_load, which does the actual loading
7568 given contents and size, apart from frame and image structures, 7584 given contents and size, apart from frame and image structures,
7569 passed from imagemagick_load. Uses librimagemagick to do most of 7585 passed from imagemagick_load. Uses librimagemagick to do most of
@@ -7618,6 +7634,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
7618 image = image_spec_value (img->spec, QCindex, NULL); 7634 image = image_spec_value (img->spec, QCindex, NULL);
7619 ino = INTEGERP (image) ? XFASTINT (image) : 0; 7635 ino = INTEGERP (image) ? XFASTINT (image) : 0;
7620 ping_wand = NewMagickWand (); 7636 ping_wand = NewMagickWand ();
7637 /* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */
7621 7638
7622 if (filename != NULL) 7639 if (filename != NULL)
7623 { 7640 {
@@ -7628,7 +7645,12 @@ imagemagick_load_image (struct frame *f, struct image *img,
7628 status = MagickPingImageBlob (ping_wand, contents, size); 7645 status = MagickPingImageBlob (ping_wand, contents, size);
7629 } 7646 }
7630 7647
7631 MagickSetResolution (ping_wand, 2, 2); 7648 if (status == MagickFalse)
7649 {
7650 imagemagick_error (ping_wand);
7651 DestroyMagickWand (ping_wand);
7652 return 0;
7653 }
7632 7654
7633 if (! (0 <= ino && ino < MagickGetNumberImages (ping_wand))) 7655 if (! (0 <= ino && ino < MagickGetNumberImages (ping_wand)))
7634 { 7656 {
@@ -7669,7 +7691,10 @@ imagemagick_load_image (struct frame *f, struct image *img,
7669 { 7691 {
7670 image_wand = NewMagickWand (); 7692 image_wand = NewMagickWand ();
7671 if (MagickReadImageBlob (image_wand, contents, size) == MagickFalse) 7693 if (MagickReadImageBlob (image_wand, contents, size) == MagickFalse)
7672 goto imagemagick_error; 7694 {
7695 imagemagick_error (image_wand);
7696 goto imagemagick_error;
7697 }
7673 } 7698 }
7674 7699
7675 /* If width and/or height is set in the display spec assume we want 7700 /* 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,
7697 if (status == MagickFalse) 7722 if (status == MagickFalse)
7698 { 7723 {
7699 image_error ("Imagemagick scale failed", Qnil, Qnil); 7724 image_error ("Imagemagick scale failed", Qnil, Qnil);
7725 imagemagick_error (image_wand);
7700 goto imagemagick_error; 7726 goto imagemagick_error;
7701 } 7727 }
7702 } 7728 }
@@ -7751,6 +7777,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
7751 if (status == MagickFalse) 7777 if (status == MagickFalse)
7752 { 7778 {
7753 image_error ("Imagemagick image rotate failed", Qnil, Qnil); 7779 image_error ("Imagemagick image rotate failed", Qnil, Qnil);
7780 imagemagick_error (image_wand);
7754 goto imagemagick_error; 7781 goto imagemagick_error;
7755 } 7782 }
7756 } 7783 }
@@ -7975,7 +8002,7 @@ recognize as images, such as C. See `imagemagick-types-inhibit'. */)
7975 Qimagemagicktype = intern (imtypes[i]); 8002 Qimagemagicktype = intern (imtypes[i]);
7976 typelist = Fcons (Qimagemagicktype, typelist); 8003 typelist = Fcons (Qimagemagicktype, typelist);
7977 } 8004 }
7978 return typelist; 8005 return Fnreverse (typelist);
7979} 8006}
7980 8007
7981#endif /* defined (HAVE_IMAGEMAGICK) */ 8008#endif /* defined (HAVE_IMAGEMAGICK) */