From unknown Sun Aug 10 10:02:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#41886 <41886@debbugs.gnu.org> To: bug#41886 <41886@debbugs.gnu.org> Subject: Status: 27.1; Rotated image doesn't fit to window height Reply-To: bug#41886 <41886@debbugs.gnu.org> Date: Sun, 10 Aug 2025 17:02:46 +0000 retitle 41886 27.1; Rotated image doesn't fit to window height reassign 41886 emacs submitter 41886 Juri Linkov severity 41886 normal tag 41886 fixed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 15 20:03:06 2020 Received: (at submit) by debbugs.gnu.org; 16 Jun 2020 00:03:06 +0000 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 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 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 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 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) From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: 27.1; Rotated image doesn't fit to window height Organization: LINKOV.NET Date: Tue, 16 Jun 2020 02:27:31 +0300 Message-ID: <87sgevanmc.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --=-=-= 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) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 16 10:46:52 2020 Received: (at 41886) by debbugs.gnu.org; 16 Jun 2020 14:46:52 +0000 Received: from localhost ([127.0.0.1]:49370 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlCrU-0002hL-Gl for submit@debbugs.gnu.org; Tue, 16 Jun 2020 10:46:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50074) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlCrS-0002h9-P3 for 41886@debbugs.gnu.org; Tue, 16 Jun 2020 10:46:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57575) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCrM-0003f9-C8; Tue, 16 Jun 2020 10:46:44 -0400 Received: from [176.228.60.248] (port=1367 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jlCrL-0000y1-Np; Tue, 16 Jun 2020 10:46:44 -0400 Date: Tue, 16 Jun 2020 17:46:24 +0300 Message-Id: <83k1071327.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87sgevanmc.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 16 Jun 2020 02:27:31 +0300) Subject: Re: bug#41886: 27.1; Rotated image doesn't fit to window height References: <87sgevanmc.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41886 Cc: 41886@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Date: Tue, 16 Jun 2020 02:27:31 +0300 > > 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: Thanks, this is okay for the release branch. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 16 18:59:36 2020 Received: (at control) by debbugs.gnu.org; 16 Jun 2020 22:59:36 +0000 Received: from localhost ([127.0.0.1]:49865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlKYK-0006Nx-1Y for submit@debbugs.gnu.org; Tue, 16 Jun 2020 18:59:36 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:60895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlKYH-0006Nh-FY for control@debbugs.gnu.org; Tue, 16 Jun 2020 18:59:34 -0400 X-Originating-IP: 91.129.108.6 Received: from mail.gandi.net (m91-129-108-6.cust.tele2.ee [91.129.108.6]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 95956C0002 for ; Tue, 16 Jun 2020 22:59:26 +0000 (UTC) From: Juri Linkov To: control@debbugs.gnu.org Subject: Re: bug#41886: 27.1; Rotated image doesn't fit to window height Organization: LINKOV.NET References: <87sgevanmc.fsf@mail.linkov.net> <83k1071327.fsf@gnu.org> Date: Wed, 17 Jun 2020 01:59:04 +0300 In-Reply-To: <83k1071327.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 16 Jun 2020 17:46:24 +0300") Message-ID: <87o8pifwhz.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) tags 41886 fixed close 41886 27.1 quit >> 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: > > Thanks, this is okay for the release branch. Fix pushed to emacs-27. From unknown Sun Aug 10 10:02:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 15 Jul 2020 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator