There's a recent reddit post asking how to view webp images in Emacs. I didn't know the answer, but it's something I had wanted for some time. This post was a nice reminder to go and check things out. Was happy to contribute an answer.
Turns out, it's very simple. Just set image-use-external-converter
and install relevant external tools.
(setq image-use-external-converter t)
I'm a use-package
user, so I prefer to set with:
(use-package image
:custom
;; Enable converting external formats (ie. webp) to internal ones.
(image-use-external-converter t))
So what are the external tools needed? C-h v
image-use-external-converter
gives us the info we need:
If non-nil, create-image will use external converters for exotic formats.
Emacs handles most of the common image formats (SVG, JPEG, PNG, GIF and some others) internally, but images that don't have native support in Emacs can still be displayed if an external conversion program (like ImageMagick "convert", GraphicsMagick "gm" or "ffmpeg") is installed.
This variable was added, or its default value changed, in Emacs 27.1.
I happen to be a macOS user, so I install ImageMagick with:
brew install imagemagick