all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dima Kogan <dima@secretsauce.net>
To: 22591@debbugs.gnu.org
Subject: bug#22591: 25.0.50; [PATCH] imagemagick orientation EXIF tag is respected
Date: Sun, 07 Feb 2016 14:54:39 -0800	[thread overview]
Message-ID: <87a8nc2ksw.fsf@secretsauce.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

Hi. Here are two small patches to improve handling of images loaded with
the imagemagick backend. They are:

1. Accept integer :rotation parameters. Previously only floating-point
ones worked

2. If an EXIF orientation tag exists and no explicit :rotation exists,
use the orientation. This happens early in the processing, so all the
data (width, height, etc) that emacs sees applies to the rotated image.

The motivation for this was that I was tired of seeing upside-down
photos in my mu4e mail.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-imagemagick-images-accept-integer-rotation-specs.patch --]
[-- Type: text/x-diff, Size: 1004 bytes --]

From 8e7e3d54f6202be3dbff34fd822d259d394fa318 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Sun, 7 Feb 2016 10:37:31 -0800
Subject: [PATCH 1/2] imagemagick images accept integer :rotation specs

* src/image.c (imagemagick_load_image):
previously we only accepted floating-point specifications, even though
the most common rotations are 90, 180 and 270. Now integers work too.
---
 src/image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/image.c b/src/image.c
index 144fe30..133d696 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8646,7 +8646,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);
-- 
2.1.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-imagemagick-respects-the-orientation-EXIF-tag.patch --]
[-- Type: text/x-diff, Size: 1259 bytes --]

From b070fb5f8b4e9cb84e15a8a7970e4dcb25696d1c Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Sun, 7 Feb 2016 14:43:24 -0800
Subject: [PATCH 2/2] imagemagick respects the orientation EXIF tag

* 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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/image.c b/src/image.c
index 133d696..45abfc7 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8546,6 +8546,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);
-- 
2.1.4


             reply	other threads:[~2016-02-07 22:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-07 22:54 Dima Kogan [this message]
2016-02-09  3:02 ` bug#22591: 25.0.50; [PATCH] imagemagick orientation EXIF tag is respected Lars Ingebrigtsen
2016-02-10  4:40   ` Lars Ingebrigtsen
2016-02-10 16:35     ` Glenn Morris
2016-02-11  2:28       ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a8nc2ksw.fsf@secretsauce.net \
    --to=dima@secretsauce.net \
    --cc=22591@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.