I use eww to open an image from wikipedia:


Now, I wanted to save it to my computer.

How can I do that?

1 Answer 1


As far as I can tell *eww* buffers store image data in the display text property.

So, to save an image we need to get this property and save it to a file.

Here is a sketch of a solution.

(defun my-eww-save-image (filename)
  "Save an image opened in an *eww* buffer to a file."
  (interactive "G")
  (let ((image (get-text-property (point-min) 'display)))
      (setq buffer-file-name filename)
       (plist-get (if (eq (car image) 'image) (cdr image)) :data))

This code seems to work in the case I tested it on, but it has at least two flaws:

  • It cannot detect the file type or the file name, so you have to specify the file name with an extension.
  • save-buffer calls hooks in before-save-hooks and after-save-hooks, which does not really make sense here.

If you know how to improve this, please go right ahead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.