I wouldn't necessarily call this simple but it is kind of a fun hack. This solution works on Linux and requires
All it requires is a "copy" from the Google Doc as normal (Ctrl+c or right-click and Copy on the image), and then an execution of a one-liner CLI command in a terminal to "fix" the clipboard so that it contains the actual image.
When copying an image from a Google Doc in Chrome, the clipboard contains the following data types:
$ xclip -selection clipboard -o -t TARGETS
Ok, we've got some HTML in there, and inspecting that, we have an
img tag with a source URL. So all we have to do is extract the URL from the HTML, download it via curl, and send that output back to the clipboard!
Here we go:
$(xclip -selection clipboard -o -t text/html \
| xmllint --html -xpath "string(//img/@src)" -) -o - \
| xclip -selection clipboard -target image/png
Breaking that down into parts:
xclip -selection clipboard -o -t text/html command extracts the HTML from the clipboard and writes it to standard output.
- That HTML output is piped through
xmllint --html -xpath "string(/html/body//img/@src)" - in order to extract the URL to standard output, which points to a Google Docs content server.
- The URL is provided as a parameter to
curl, which downloads the content and writes it to standard output.
- The downloaded image data is piped back into the clipboard as an
xclip -selection clipboard -target image/png.
Note here we assume at step 4 that the image is a PNG, which seems to be a fair assumption for images stored in Google Docs. If that assumption does not hold, variations on this theme are of course possible in which we buffer the output of curl to a temporary file, inspect it via
file, and then set the clipboard target appropriately, which can all be easily scripted.