diff options
| author | Juri Linkov | 2020-06-17 01:58:32 +0300 |
|---|---|---|
| committer | Juri Linkov | 2020-06-17 01:58:32 +0300 |
| commit | 1dff0a89497fec15297a97fcd643ea8475f704da (patch) | |
| tree | 2bdc14c644272f153d8ec8185908263691fa7cb7 | |
| parent | a71d1787f128c642f8a1fb297ef5043e20218646 (diff) | |
| download | emacs-1dff0a89497fec15297a97fcd643ea8475f704da.tar.gz emacs-1dff0a89497fec15297a97fcd643ea8475f704da.zip | |
* lisp/image-mode.el (image-toggle-display-image): Fix fit of rotated images.
When fitting rotated image to width and height, swap width and height
when changing orientation between portrait and landscape (bug#41886).
| -rw-r--r-- | lisp/image-mode.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index b82c0669187..1bb213c2489 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el | |||
| @@ -810,8 +810,12 @@ was inserted." | |||
| 810 | filename)) | 810 | filename)) |
| 811 | ;; If we have a `fit-width' or a `fit-height', don't limit | 811 | ;; If we have a `fit-width' or a `fit-height', don't limit |
| 812 | ;; the size of the image to the window size. | 812 | ;; the size of the image to the window size. |
| 813 | (edges (and (eq image-transform-resize t) | 813 | (edges (when (eq image-transform-resize t) |
| 814 | (window-inside-pixel-edges (get-buffer-window)))) | 814 | (window-inside-pixel-edges (get-buffer-window)))) |
| 815 | (max-width (when edges | ||
| 816 | (- (nth 2 edges) (nth 0 edges)))) | ||
| 817 | (max-height (when edges | ||
| 818 | (- (nth 3 edges) (nth 1 edges)))) | ||
| 815 | (type (if (image--imagemagick-wanted-p filename) | 819 | (type (if (image--imagemagick-wanted-p filename) |
| 816 | 'imagemagick | 820 | 'imagemagick |
| 817 | (image-type file-or-data nil data-p))) | 821 | (image-type file-or-data nil data-p))) |
| @@ -827,14 +831,18 @@ was inserted." | |||
| 827 | (ignore-error exif-error | 831 | (ignore-error exif-error |
| 828 | (exif-parse-buffer))) | 832 | (exif-parse-buffer))) |
| 829 | 0.0))) | 833 | 0.0))) |
| 834 | ;; Swap width and height when changing orientation | ||
| 835 | ;; between portrait and landscape. | ||
| 836 | (when (and edges (zerop (mod (+ image-transform-rotation 90) 180))) | ||
| 837 | (setq max-width (prog1 max-height (setq max-height max-width)))) | ||
| 830 | 838 | ||
| 831 | ;; :scale 1: If we do not set this, create-image will apply | 839 | ;; :scale 1: If we do not set this, create-image will apply |
| 832 | ;; default scaling based on font size. | 840 | ;; default scaling based on font size. |
| 833 | (setq image (if (not edges) | 841 | (setq image (if (not edges) |
| 834 | (create-image file-or-data type data-p :scale 1) | 842 | (create-image file-or-data type data-p :scale 1) |
| 835 | (create-image file-or-data type data-p :scale 1 | 843 | (create-image file-or-data type data-p :scale 1 |
| 836 | :max-width (- (nth 2 edges) (nth 0 edges)) | 844 | :max-width max-width |
| 837 | :max-height (- (nth 3 edges) (nth 1 edges))))) | 845 | :max-height max-height))) |
| 838 | 846 | ||
| 839 | ;; Discard any stale image data before looking it up again. | 847 | ;; Discard any stale image data before looking it up again. |
| 840 | (image-flush image) | 848 | (image-flush image) |