Function: image-convert-p

image-convert-p is a byte-compiled function defined in image-converter.el.gz.

Signature

(image-convert-p SOURCE &optional DATA-P)

Documentation

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 specifying the image type, like "image/gif".

Source Code

;; Defined in /usr/src/emacs/lisp/image/image-converter.el.gz
(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 specifying the image type,
like \"image/gif\"."
  (image-converter-initialize)
  ;; When image-converter was customized
  (when (and image-converter (not image-converter-regexp))
    (when-let ((formats (image-converter--probe image-converter)))
      (setq image-converter-regexp
            (concat "\\." (regexp-opt formats) "\\'"))
      (setq image-converter-file-name-extensions formats)))
  (and image-converter
       (or (and (not data-p)
                (string-match image-converter-regexp source))
           (and data-p
                (symbolp data-p)
                (string-search "/" (symbol-name data-p))
                (string-match
                 image-converter-regexp
                 (concat "foo." (image-converter--mime-type data-p)))))
       'image-convert))