From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#41886: 27.1; Rotated image doesn't fit to window height Date: Tue, 16 Jun 2020 02:27:31 +0300 Organization: LINKOV.NET Message-ID: <87sgevanmc.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="123893"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) To: 41886@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 16 02:04:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jkz5H-000WCK-Du for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Jun 2020 02:04:11 +0200 Original-Received: from localhost ([::1]:53626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkz5G-0000KS-Cx for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Jun 2020 20:04:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkz58-0000Jw-Dk for bug-gnu-emacs@gnu.org; Mon, 15 Jun 2020 20:04:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkz58-0007En-4H for bug-gnu-emacs@gnu.org; Mon, 15 Jun 2020 20:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jkz58-0007zd-0n for bug-gnu-emacs@gnu.org; Mon, 15 Jun 2020 20:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Jun 2020 00:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41886 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.159226578630658 (code B ref -1); Tue, 16 Jun 2020 00:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Jun 2020 00:03:06 +0000 Original-Received: from localhost ([127.0.0.1]:47701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkz4D-0007yL-S9 for submit@debbugs.gnu.org; Mon, 15 Jun 2020 20:03:06 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkz4A-0007xR-5U for submit@debbugs.gnu.org; Mon, 15 Jun 2020 20:03:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkz49-0007jV-Ur for bug-gnu-emacs@gnu.org; Mon, 15 Jun 2020 20:03:01 -0400 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:53815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkz47-0006z3-St for bug-gnu-emacs@gnu.org; Mon, 15 Jun 2020 20:03:01 -0400 Original-Received: from mail.gandi.net (m91-129-108-6.cust.tele2.ee [91.129.108.6]) (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 729F5200004; Tue, 16 Jun 2020 00:02:55 +0000 (UTC) Received-SPF: pass client-ip=217.70.178.232; envelope-from=juri@linkov.net; helo=relay12.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/15 20:02:56 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182005 Archived-At: --=-=-= Content-Type: text/plain Version: 27.1 Tags: patch I found a bug in image-mode on emacs-27. Using the default value 't' of 'image-transform-resize' (that means to fit the image to the window height and width), when an image has exif-orientation 90 and visited in image-mode, it's rotated, but doesn't fit to the window height, only the upper half of the image is displayed. The patch that fixes this problem: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=image-mode-fit-rotated-image.patch diff --git a/lisp/image-mode.el b/lisp/image-mode.el index b82c066918..019f6e20ce 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -810,8 +810,12 @@ image-toggle-display-image filename)) ;; If we have a `fit-width' or a `fit-height', don't limit ;; the size of the image to the window size. - (edges (and (eq image-transform-resize t) - (window-inside-pixel-edges (get-buffer-window)))) + (edges (when (eq image-transform-resize t) + (window-inside-pixel-edges (get-buffer-window)))) + (max-width (when edges + (- (nth 2 edges) (nth 0 edges)))) + (max-height (when edges + (- (nth 3 edges) (nth 1 edges)))) (type (if (image--imagemagick-wanted-p filename) 'imagemagick (image-type file-or-data nil data-p))) @@ -827,14 +831,18 @@ image-toggle-display-image (ignore-error exif-error (exif-parse-buffer))) 0.0))) + ;; Swap width and height when changing orientation + ;; between portrait and landscape. + (when (and edges (memq (truncate image-transform-rotation) '(90 270))) + (setq max-width (prog1 max-height (setq max-height max-width)))) ;; :scale 1: If we do not set this, create-image will apply ;; default scaling based on font size. (setq image (if (not edges) (create-image file-or-data type data-p :scale 1) (create-image file-or-data type data-p :scale 1 - :max-width (- (nth 2 edges) (nth 0 edges)) - :max-height (- (nth 3 edges) (nth 1 edges))))) + :max-width max-width + :max-height max-height))) ;; Discard any stale image data before looking it up again. (image-flush image) --=-=-=--