From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#22591: 25.0.50; [PATCH] imagemagick orientation EXIF tag is respected Date: Sun, 07 Feb 2016 14:54:39 -0800 Message-ID: <87a8nc2ksw.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1454885725 24597 80.91.229.3 (7 Feb 2016 22:55:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Feb 2016 22:55:25 +0000 (UTC) To: 22591@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 07 23:55:13 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aSYEa-0005Kj-Ou for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Feb 2016 23:55:13 +0100 Original-Received: from localhost ([::1]:38944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSYEa-0002oX-Ax for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Feb 2016 17:55:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSYEU-0002js-5E for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:55:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSYEQ-0007GO-Td for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:55:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSYEQ-0007GK-QE for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aSYEQ-0005pj-KX for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2016 22:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22591 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.145488569922409 (code B ref -1); Sun, 07 Feb 2016 22:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Feb 2016 22:54:59 +0000 Original-Received: from localhost ([127.0.0.1]:37693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aSYEM-0005pM-RK for submit@debbugs.gnu.org; Sun, 07 Feb 2016 17:54:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:32802) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aSYEK-0005p9-7F for submit@debbugs.gnu.org; Sun, 07 Feb 2016 17:54:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSYED-0007Ef-UP for submit@debbugs.gnu.org; Sun, 07 Feb 2016 17:54:50 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:55484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSYED-0007Eb-Qr for submit@debbugs.gnu.org; Sun, 07 Feb 2016 17:54:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSYEC-0002M9-GR for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:54:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSYE9-0007DR-2R for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:54:48 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSYE8-0007Ci-RB for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 17:54:44 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3694D20875 for ; Sun, 7 Feb 2016 17:54:43 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Sun, 07 Feb 2016 17:54:43 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=content-type:date:from:message-id:mime-version:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=yCafzm7WxvlaHR47iHAVppCWNRM =; b=iwtK2WlX+BOel0rjL0Kkz9iVSHXQFMUDPLHww/K+zr8UQVGzSHXw71979fN 5E/EjzAGGQYJ3PWFVensvU7nMs+FiA9nfG2sWqL7Xa4pwL49o1essmzkDznhcUwm r3w87gZmDKBYepXZ5P1DhmCs4CB5EBdSTOo+KueyYGtIXxuU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=yC afzm7WxvlaHR47iHAVppCWNRM=; b=RgP0toEoQOq/DMU6NpmCVL1D9pwIEKj9N/ W/ldkP+aqOIgWK62u2YyQoNsaF0Mbv9CgLuXGXRkBZz5gN/ssvkqsFLDC06IP4VA TJMbyFDAqeN4cnv83NFjwAk0FY2gXk9YJF1pKY8OO+nBxd10Vtjv2/QXCXBuA4m8 ZWs+ZVNWU= X-Sasl-enc: n/qt0tFwFxpCq2s+dMZfhbYiMJZZT4NBdWRK5r5R4zzt 1454885682 Original-Received: from shorty.local (cpe-108-185-223-73.socal.res.rr.com [108.185.223.73]) by mail.messagingengine.com (Postfix) with ESMTPA id BFD8A680218 for ; Sun, 7 Feb 2016 17:54:42 -0500 (EST) Original-Received: from localhost ([::1] helo=shorty) by shorty.local with esmtp (Exim 4.84) (envelope-from ) id 1aSYE3-0004lo-Ec for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2016 14:54:39 -0800 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112673 Archived-At: --=-=-= Content-Type: text/plain 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! --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-imagemagick-images-accept-integer-rotation-specs.patch >From 8e7e3d54f6202be3dbff34fd822d259d394fa318 Mon Sep 17 00:00:00 2001 From: Dima Kogan 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-imagemagick-respects-the-orientation-EXIF-tag.patch >From b070fb5f8b4e9cb84e15a8a7970e4dcb25696d1c Mon Sep 17 00:00:00 2001 From: Dima Kogan 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 --=-=-=--