(put 'image-mode 'mode-class 'special)
+(declare-function image-converter-initialize "image-converter.el")
+
;;;###autoload
(defun image-mode ()
"Major mode for image files.
"Empty file"
"(New file)")
"Empty buffer"))
- (image-mode--display)))
+ (image-mode--display)
+ ;; Ensure that we recognize externally parsed image formats in
+ ;; commands like `n'.
+ (when image-use-external-converter
+ (require 'image-converter)
+ (image-converter-initialize))))
(defun image-mode--display ()
(if (not (image-get-display-property))
(imagemagick :command "convert" :probe ("-list" "format")))
"List of supported image converters to try.")
+(defun image-converter-initialize ()
+ "Determine the external image converter to be used.
+This also determines which external formats we can parse."
+ (unless image-converter
+ (image-converter--find-converter)))
+
(defun image-convert-p (source &optional data-p)
"Return `image-convert' if SOURCE is an image that can be converted.
SOURCE can either be a file name or a string containing image
data. In the latter case, DATA-P should be non-nil. If DATA-P
is a string, it should be a MIME format string like
\"image/gif\"."
- ;; Find an installed image converter.
- (unless image-converter
- (image-converter--find-converter))
+ (image-converter-initialize)
;; When image-converter was customized
(when (and image-converter (not image-converter-regexp))
(when-let ((formats (image-converter--probe image-converter)))
This function converts the image the preferred format, and the
converted image data is returned as a string."
- ;; Find an installed image converter.
- (unless image-converter
- (image-converter--find-converter))
+ (image-converter-initialize)
(unless image-converter
(error "No external image converters available"))
(when (and image-format