diff options
| author | Lars Ingebrigtsen | 2019-06-12 19:00:37 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-12 19:00:43 +0200 |
| commit | 2d71e68428b10c593da2dd411d70ed2b4a8632c0 (patch) | |
| tree | 665a84ebab0d5a837fcd3399ebf32af2297052ed | |
| parent | 26f2b1faaa1dc8847f2013268c20f51c144ae711 (diff) | |
| download | emacs-2d71e68428b10c593da2dd411d70ed2b4a8632c0.tar.gz emacs-2d71e68428b10c593da2dd411d70ed2b4a8632c0.zip | |
Restore image scaling support when there's no native image scaling
* lisp/net/shr.el (shr--image-type): New function.
(shr-rescale-image): Use it to allow image scaling on Emacsen with
ImageMagick support that does not have native image scaling support.
| -rw-r--r-- | lisp/net/shr.el | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index c1e9fdd30d7..a014c56948c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el | |||
| @@ -1093,6 +1093,16 @@ element is the data blob and the second element is the content-type." | |||
| 1093 | image) | 1093 | image) |
| 1094 | (insert (or alt "")))) | 1094 | (insert (or alt "")))) |
| 1095 | 1095 | ||
| 1096 | (defun shr--image-type () | ||
| 1097 | "Emacs image type to use when displaying images. | ||
| 1098 | If Emacs has native image scaling support, that's used, but if | ||
| 1099 | not, `imagemagick' is preferred if it's present." | ||
| 1100 | (if (or (and (fboundp 'image-transforms-p) | ||
| 1101 | (image-transforms-p)) | ||
| 1102 | (not (fboundp 'imagemagick-types))) | ||
| 1103 | nil | ||
| 1104 | 'imagemagick)) | ||
| 1105 | |||
| 1096 | (defun shr-rescale-image (data content-type width height | 1106 | (defun shr-rescale-image (data content-type width height |
| 1097 | &optional max-width max-height) | 1107 | &optional max-width max-height) |
| 1098 | "Rescale DATA, if too big, to fit the current buffer. | 1108 | "Rescale DATA, if too big, to fit the current buffer. |
| @@ -1122,13 +1132,13 @@ width/height instead." | |||
| 1122 | (< (* width scaling) max-width) | 1132 | (< (* width scaling) max-width) |
| 1123 | (< (* height scaling) max-height)) | 1133 | (< (* height scaling) max-height)) |
| 1124 | (create-image | 1134 | (create-image |
| 1125 | data nil t | 1135 | data (shr--image-type) t |
| 1126 | :ascent 100 | 1136 | :ascent 100 |
| 1127 | :width width | 1137 | :width width |
| 1128 | :height height | 1138 | :height height |
| 1129 | :format content-type) | 1139 | :format content-type) |
| 1130 | (create-image | 1140 | (create-image |
| 1131 | data nil t | 1141 | data (shr--image-type) t |
| 1132 | :ascent 100 | 1142 | :ascent 100 |
| 1133 | :max-width max-width | 1143 | :max-width max-width |
| 1134 | :max-height max-height | 1144 | :max-height max-height |