If I do a screenshot to clipboard like this:

xsnap -png -stdout | xclip -selection primary -t image/png

.....then a middle-mouse-button-paste to thunderbird yields a binary paste starting with '�PNG IHDR' and bunch of gibberish (binary data).

If I instead do a middle-mouse-button-paste to libreoffice first (yes, this works), then I can paste an image into thunderbird successfully. No explicit copy (select or ctrl-c) from libreoffice required.

I expect half the reason for this is that libreoffice modifies the selection the moment I paste there. So there is a recognizable (by thunderbird) image in the selection buffer after libreoffice is done.

But I can also do:

xsnap -png -stdout | xclip -selection primary -t image/png
xclip -selection primary -t image/png -o > beforepastetolibreoffce.png

...and insert beforepastetolibreoffce.png into thunderbird.

If I paste to libreoffice and do:

xclip -selection primary -t image/png -o > afterpastetolibreoffice.png

.... I end up with:

-rw-r--r-- 1 dagb dagb  6505 aug.  21 13:48 beforepastetolibreoffice.png
-rw-r--r-- 1 dagb dagb 27914 aug.  21 13:49 afterpastetolibreoffice.png

...confirming my theory above. libreoffice modifies the primary selection.

thunderbird is equally unhappy about the jpeg format which xclip writes to the primary selection buffer.

I believe I have an idea about what happens here. But how do I approach debugging this further? Unsure if the bug here lies with xclip or firefox, even if libreoffice can parse the selection buffer as written by xclip.

  • Did you ever find a fix for this? This problem has been here for a very long time.
    – scippie
    Feb 23, 2021 at 11:45
  • No, sorry. The problem appears to still be present.
    – Dag B
    Jun 20, 2021 at 10:19

2 Answers 2


There is a workaround: Thunderbird can process images from the clipboard when they are offered as text/html and the content in the clipboard is the image encoded as base64 in an img html tag.

This can be achieved by the command line shown below. It expects the image as binary data in the clipboard with the mime type image/png and encodes it as html and stores it back to the clipboard with mime type text/html. Then, in thunderbird, using paste will work. The command below uses wl-paste and wl-copy, which interact with the wayland clipboard.

wl-paste -t image/png | base64 -w 0 | sed 's/^/<img src="data:image\/jpeg;base64,/g' | sed 's/$/">/g' | wl-copy -t text/html
  • Awesome, any idea how to keep it compatible with other apps though? Btw., you can save one sed call by replacing ' | sed' with ; :-)
    – exic
    Jul 8, 2022 at 8:16

Install https://addons.thunderbird.net/en-US/thunderbird/addon/attach-from-clipboard/ then use CTRL+V after copying an image from clipboard (eg. using some "select region to copy as screenshot" tool). This should paste an image, not binary data

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.