diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2020-08-22 15:18:15 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2020-08-22 15:18:15 +0200 |
commit | 0aa4647f9cc53f3ded2c1bdea3d9f44962d318c0 (patch) | |
tree | 355acd687db5a50c6bd014702016d44ab7b28a06 /lisp/image | |
parent | 61fc4bf286da9081b822e9280e351ce7045868dc (diff) | |
download | emacs-0aa4647f9cc53f3ded2c1bdea3d9f44962d318c0.tar.gz emacs-0aa4647f9cc53f3ded2c1bdea3d9f44962d318c0.tar.bz2 emacs-0aa4647f9cc53f3ded2c1bdea3d9f44962d318c0.zip |
Restrict the range of image formats to be converted
* lisp/image/image-converter.el (image-converter--filter-formats):
New function.
(image-converter): Mention this in the doc string.
Diffstat (limited to 'lisp/image')
-rw-r--r-- | lisp/image/image-converter.el | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lisp/image/image-converter.el b/lisp/image/image-converter.el index ee1dc845fb5..c31a3b8d3cf 100644 --- a/lisp/image/image-converter.el +++ b/lisp/image/image-converter.el @@ -33,8 +33,15 @@ "Type of the external image converter to use. The value should a symbol, either `imagemagick', `graphicsmagick', or `ffmpeg'. + If nil, Emacs will try to find one of the supported converters -installed on the system." +installed on the system. + +The actual range of image formats that will be converted depends +on what image formats the chosen converter reports being able to +handle. `auto-mode-alist' is then used to further filter what +formats that are to be supported: Only the suffixes that map to +`image-mode' will be handled." :group 'image :type 'symbol :version "27.1") @@ -186,12 +193,25 @@ data is returned as a string." "Find an installed image converter." (catch 'done (dolist (elem image-converter--converters) - (when-let ((formats (image-converter--probe (car elem)))) + (when-let ((formats (image-converter--filter-formats + (image-converter--probe (car elem))))) (setq image-converter (car elem) image-converter-regexp (concat "\\." (regexp-opt formats) "\\'") image-converter-file-name-extensions formats) (throw 'done image-converter))))) +(defun image-converter--filter-formats (suffixes) + "Filter SUFFIXES based on `auto-mode-alist'. +Only suffixes that map to `image-mode' are returned." + (cl-loop with case-fold-search = (if (not auto-mode-case-fold) + nil + t) + for suffix in suffixes + when (eq (cdr (assoc (concat "foo." suffix) auto-mode-alist + #'string-match)) + 'image-mode) + collect suffix)) + (cl-defmethod image-converter--convert ((type (eql graphicsmagick)) source image-format) "Convert using GraphicsMagick." |