Subject: bug#39994: 27.0.90; Broken image-converter probe for imagemagick

From: Juri Linkov <[email-masked]>
Date: Mon, 16 Mar 2020 02:04:58 +0200

reopen 39994
tags 39994 - fixed
quit

>> We put imagemagick at the end because of the same reason we're
>> deprecating libmagick in Emacs -- imagemagick has had en enormous number
>> of exploitable bugs over the years.  Running external programs mitigates
>> this slightly, but it should remain the last option.
>
> Right.  I moved it up only because I was lazy to restart Emacs -
> currently customization of image-converter requires restarting Emacs,
> but it's not a big problem.

Sorry, I misremembered - actually it *is* a problem,
since handling customization is not yet implemented.

Here is a possible implementation:

diff --git a/lisp/image/image-converter.el b/lisp/image/image-converter.el
index 0488a13d41..4efae5c202 100644
--- a/lisp/image/image-converter.el
+++ b/lisp/image/image-converter.el
@@ -57,6 +57,10 @@ image-convert-p
   ;; Find an installed image converter.
   (unless image-converter
     (image-converter--find-converter))
+  ;; When image-converter was customized
+  (if (and image-converter (not image-converter-regexp))
+      (when-let ((formats (image-converter--probe image-converter)))
+        (setq image-converter-regexp (concat "\\." (regexp-opt formats) "\\'"))))
   (and image-converter
        (or (and (not data-p)
                 (string-match image-converter-regexp source))