r/swaywm • u/mindstormer12 • 10h ago
Question Pasting image from clipboard without conversion?
Finally decided clipboard manager is worth using.
Is it possible to default to copy and paste image without converting image format? My understanding is that on pasting content that was copied from a source app, wl-clipboard gets a list of supported formats from source app and infers which is preferred/default to get, however, it doesn't seem to pick the the original format and a converted format of much larger size gets picked instead, example: image is a 287.92K jpeg file when downloaded by wget or saved by Firefox.
With a clipboard manager with wl-paste (wl-paste --type image --watch clipvault store), copying the image from Firefox and "pasting" (saved by the clipboard manager), it becomes a whopping 2 MB png file. This is fixed if instead I explicitly set the format to be jpeg for wl-paste: wl-paste --type image/jpeg --watch clipvault store. Presumably the original file is only a 287K jpeg file and the converted file is the 2 MB png file, but more importantly, the guess of png was not a good one.
Specifying a specific image format only solves this particular case (and perhaps not even for the Firefox app itself, just this particular file), what if I don't want conversion of image files from any apps which seems to be the more intuitive behavior to preserve quality (and in this scenario ensuring reasonable size of image)? Is the approach to run multiple wl-paste instances? This approach will mean the clipboard manager will store multiple formats for the same image and it's not clear which is the original copy that's not converted (I would have thought the larger 2 MB png file is the original).
I don't want the clipboard manager to save multiple formats of a file--ideally it saves "the original file, but convert if it exceeds e.g. 10 MB in size)". If I'm copying the image from one application to another, I only want/expect it to be the original image in quality and size. As-is it seems like a strange limitation with how clipboard works, e.g. that the source app (Firefox) provides a list of available formats but with no way to "prefer" the original (or "ideal") format and the destination app (wl-clipboard) can only guess. The destination client has the choice, but not an informed one (they would have to download all the available formats provided by the source). AFAIK there's no decent solution to the problem.


