I have seen some posts on this but I decided to ask anyway since this is an important feature many users are requesting: the ability to copy an image from eg., Chrome and paste it into Emacs Orgmode buffer. Is this possible in 2022?
3 Answers
Org-mode files are 'designed' to be plain text files, therefore it is common to insert links to image files, which Emacs 'optionally' can render as an image. It is possible to insert the image data directly and let it get rendered as an image (see e.g. this thread, and its implementation in sketch-mode) but it becomes messy when the file is viewed as a plain-text file.
With this said, abo-abo's org-download package provides very much what you are asking for. It makes possible to drag-n-drop images from your browser into your org-mode file. Alternatively, using org-download-yank
it can insert the image if you provide the link to the image file (in your browser, instead of 'copy image', you choose 'copy image link').
-
2Some specific examples of how to customize
org-download
for this are discussed in this github issue.– MarkMay 16 at 20:53
Yes, (as mentioned in the other answers) by installing the org-download package.
If you are on doom emacs you can use this configuration that will save the images to a folder in a location relative to the original file when pasting them from a clipboard (with the org-download-clipboard
function):
(after! org-download
(setq org-download-method 'directory)
(setq org-download-image-dir (concat (file-name-sans-extension (buffer-file-name)) "-img"))
(setq org-download-image-org-width 600)
(setq org-download-link-format "[[file:%s]]\n"
org-download-abbreviate-filename-function #'file-relative-name)
(setq org-download-link-format-function #'org-download-link-format-function-default))
The last three lines took about 4 hours of debugging (refer to the issue 151)
references:
There is no built-in way of pasting images from the clipboard directly, but attachments provide decent ways of adding images from other sources.
If you want to copy an image from a browser, you could copy the image url instead of the image itself and use org-attach
(C-c C-a) with command u
(download and attach a file from url), to attach the image to the current headline. There is also the package org-attach-screenshot to add a screenshot as attachment.
Then as written in this answer, you can set (setq org-attach-store-link-p 'attached)
to store a link to the last attached file, and it will be the default suggestion of org-insert-link
(C-c C-l). Otherwise just selecting an attachment:
-type link would let you chose among the attachments of the current headline.
You'll then need to use org-display-inline-images
to toggle the newly-added links into images.