]> code.delx.au - gnu-emacs/blobdiff - src/image.c
Merge from origin/emacs-25
[gnu-emacs] / src / image.c
index 144fe30a7466497eb0905331cd982e8c13ebf978..af65fdec7dc766a0c3b58b931715390091cb9403 100644 (file)
@@ -8073,6 +8073,7 @@ compute_image_size (size_t width, size_t height,
 {
   Lisp_Object value;
   int desired_width, desired_height;
+  double scale = 1;
 
   /* If width and/or height is set in the display spec assume we want
      to scale to those values.  If either h or w is unspecified, the
@@ -8083,6 +8084,12 @@ compute_image_size (size_t width, size_t height,
   value = image_spec_value (spec, QCheight, NULL);
   desired_height = NATNUMP (value) ? min (XFASTINT (value), INT_MAX) : -1;
 
+  value = image_spec_value (spec, QCscale, NULL);
+  if (NUMBERP (value))
+    scale = extract_float (value);
+  width = width * scale;
+  height = height * scale;
+
   if (desired_width == -1)
     {
       value = image_spec_value (spec, QCmax_width, NULL);
@@ -8132,6 +8139,13 @@ compute_image_size (size_t width, size_t height,
     /* h known, calculate w.  */
     desired_width = scale_image_size (desired_height, height, width);
 
+  /* We have no width/height settings, so just apply the scale. */
+  if (desired_width == -1 && desired_height == -1)
+    {
+      desired_width = width;
+      desired_height = height;
+    }
+
   *d_width = desired_width;
   *d_height = desired_height;
 }
@@ -8546,6 +8560,18 @@ imagemagick_load_image (struct frame *f, struct image *img,
       return 0;
     }
 
+#ifdef HAVE_MAGICKAUTOORIENTIMAGE
+  /* 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;
+      }
+#endif
+
   if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
     {
       image_error ("Invalid image number `%s' in image `%s'", image, img->spec);
@@ -9795,6 +9821,7 @@ non-numeric, there is no explicit limit on the size of images.  */);
   DEFSYM (QCcrop, ":crop");
   DEFSYM (QCrotation, ":rotation");
   DEFSYM (QCmatrix, ":matrix");
+  DEFSYM (QCscale, ":scale");
   DEFSYM (QCcolor_adjustment, ":color-adjustment");
   DEFSYM (QCmask, ":mask");