@lisp
(image-converter-add
"kra"
- (lambda (file)
- (call-process "unzip" nil t nil
- "-qq" "-c" "-x" file "mergedimage.png"))))
+ (lambda (file data-p)
+ (if data-p
+ (error "Can't decode non-files")
+ (call-process "unzip" nil t nil
+ "-qq" "-c" "-x" file "mergedimage.png"))))
@end lisp
The function takes two parameters, where the first is a file name
suffix, and the second is a function to do the ``conversion''. This
-function takes one parameter, the file name, and should output an
-image in @code{image-convert-to-format} format in the current buffer.
+function takes two parameters, where the first is the file name or a
+string with the data, and the second says whether the first parameter
+is data or not, and should output an image in
+@code{image-convert-to-format} format in the current buffer.
@findex thumbs-mode
@cindex mode, Thumbs
(file-name-extension source)))
(extra-converter (gethash type image-converter--extra-converters)))
(if extra-converter
- (funcall extra-converter source)
+ (funcall extra-converter source format)
(when-let ((err (image-converter--convert
image-converter source format)))
(error "%s" err))))
;;;###autoload
(defun image-converter-add-handler (suffix converter)
"Make Emacs use CONVERTER to parse image files that end with SUFFIX.
-CONVERTER is a function with one parameter, the file name. The
-converter should output the image in the current buffer,
-converted to `image-convert-to-format'."
+CONVERTER is a function with two parameters, where the first is
+the file name or a string with the image data, and the second is
+non-nil if the first parameter is image data. The converter
+should output the image in the current buffer, converted to
+`image-convert-to-format'."
(cl-pushnew suffix image-converter-file-name-extensions :test #'equal)
(setq image-converter-file-name-extensions
(sort image-converter-file-name-extensions #'string<))