Add more image targets to clipboard selection on X11

186 views
Skip to first unread message

Hans Müller

unread,
Feb 8, 2022, 3:59:57 AM2/8/22
to Chromium-discuss
Currently, when a image is copied, Chromium only offers image/png as a image target (you can see this by running: xclip -o -target TARGETS -selection clipboard). See the buttom of the message to see all targets it offers.

Why is this a problem?: https://www.reddit.com/r/discordapp/comments/rgqwk0/please_stop_this_nonsense_discord/
tl;dr: When e.g. a image is a small JPEG, the application the user wants to paste into can not ask for that but only for PNG cause Chromium only offers PNG and not JPEG as a target. This means that a half 430 KB JPEG might be converted to a 6.5 MB PNG as seen in the reddit post.

Here should be the parts that would need a change (I choosed to search for SAVE_TARGETS cause this is another target that chromium offers and this is pretty unique):
https://source.chromium.org/search?q=SAVE_TARGETS&ss=chromium

I suggest that some of the targets that Firefox offers are added as well as targets for new formats like a image/jxl target for JPEG-XL. Maybe we can be clever and list the best image target first/last e.g. when we have a JPEG display image/jxl, then image/jpeg and then image/png. Applications filtering for image/ targets would thus see image/jxl first (which I put first cause it is backwards compatible to JPEG and always saves space). Tho I guess applications could also parse text/html to find out what the original format of the image was and then ask again for the image but that would be... a lot of text to parse in some cases (and I guess it would be better to just introduce a new target containing the file format of the image if we would go that route.)...


All targets Chromium offers when a image is copied:
TIMESTAMP TARGETS SAVE_TARGETS MULTIPLE image/png text/html
This is what Firefox offers:
TIMESTAMP TARGETS MULTIPLE SAVE_TARGETS text/html text/_moz_htmlinfo text/_moz_htmlcontext image/png image/bmp image/x-bmp image/x-MS-bmp image/x-icon image/x-ico image/x-win-bitmap image/vnd.microsoft.icon application/ico image/ico image/icon text/ico image/jpeg image/tiff image/avif image/webp audio/x-riff
Reply all
Reply to author
Forward
0 new messages