]> code.delx.au - gnu-emacs/commitdiff
Support integer image rotation and respect EXIF rotations
authorDima Kogan <dima@secretsauce.net>
Wed, 10 Feb 2016 04:40:03 +0000 (15:40 +1100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 11 Feb 2016 03:07:48 +0000 (14:07 +1100)
* src/image.c (imagemagick_load_image): Allow integer rotations in
addition to floating point rotations (bug#22591).
* src/image.c (imagemagick_load_image): Images that have an
orientation given in EXIF and have no explicit :rotation tag are now
pre-rotated.  All information such as width/height is reported for the
rotated image.

src/image.c

index ea5d231720baef865842659459b75abb99d8be15..e1b167de3d28d3078e45fb4ec6ea46d35f1e1679 100644 (file)
@@ -8560,6 +8560,16 @@ imagemagick_load_image (struct frame *f, struct image *img,
       return 0;
     }
 
+  /* If no :rotation is explicitly specified, apply the automatic
+     rotation from EXIF. */
+  if (NILP (image_spec_value (img->spec, QCrotation, NULL)))
+    if (MagickAutoOrientImage (image_wand) == MagickFalse)
+      {
+        image_error ("Error applying automatic orientation in image `%s'", img->spec);
+        DestroyMagickWand (image_wand);
+        return 0;
+      }
+
   if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
     {
       image_error ("Invalid image number `%s' in image `%s'", image, img->spec);
@@ -8660,7 +8670,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
     image_spec_value (img->spec, QCbackground, NULL); if (!STRINGP
     (specified_bg).  */
   value = image_spec_value (img->spec, QCrotation, NULL);
-  if (FLOATP (value))
+  if (FLOATP (value) || INTEGERP (value))
     {
       rotation = extract_float (value);
       status = MagickRotateImage (image_wand, bg_wand, rotation);