xclip icon indicating copy to clipboard operation
xclip copied to clipboard

Copying jpeg to clipboard doesn't fully work

Open xadips opened this issue 4 years ago • 1 comments

When I copy a .png file to clipboard using xclip -selection clipboard -t "$type" "$file" where $type is it's mime-type, and $file is it's filename it works perfectly.

But when I do it with a .jpg file the same way xclip -selection clipboard -t "$type" "$file" pasting it only works into some of the applications f.e gimp, but it doesn't act the same like .png with discord, messenger, etc.

Is this an xclip issue, or it's just that .jpg can't be copied the same way .png can?

xadips avatar Jan 12 '21 19:01 xadips

same problem here

shufuwa avatar Jul 07 '22 15:07 shufuwa

Unfortunately, some web apps are very picky about what they will accept. For example, I've noticed the same problem pasting jpegs into Gmail. Many X clients that holds clipboard data are able to offer images in multiple formats and convert on the fly, so this usually is not a problem. Xclip doesn't do that. In fact, it currently can offer only one MIME type at a time.

This isn't pretty, but you can try something like convert foo.jpg png:- | xclip -i -sel c -t image/png


I think it would be a reasonable addition to xclip to be able to offer multiple mimetype targets simultaneously, perhaps with a way to delegate a program that can do the conversion as needed. But, I'm just a contributor. Such a major change would be something @astrand, xclip's author, would have to weigh in on. Besides the "small matter of coding", It would require a bit of planning and consideration. (E.g., are the known conversions builtin or specified in a config file? Or must the user specify them every time from the command line arguments?)

hackerb9 avatar Nov 16 '22 20:11 hackerb9

I've found a "workaround" which is to set the target to image/png even if the file is a JPEG. This works well enough to paste the image correctly in both Firefox and Chromium as well as electron based apps, at least as of this writing.

I don't think the problem here is with xclip or the X server. The problem is not even with the websites. I've filed bug reports against firefox and chromium describing this along with sample code to reproduce the issue:

  1. Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1825959
  2. Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1430187

awalgarg avatar Apr 03 '23 17:04 awalgarg

Closing as this is not an issue with xclip, hoping this gets fixed in the browsers.

xadips avatar May 15 '23 11:05 xadips