rvion / CushyStudio

🛋 The AI and Generative Art platform for everyone
https://docs.cushystudio.com/
GNU Affero General Public License v3.0
656 stars 48 forks source link

MediaImage: Add copyToClipboard function #164

Closed birdddev closed 6 months ago

birdddev commented 6 months ago

Also adds a button to "send to clipboard" in ImageDropdownUI As far as I can tell, you can only put png/jpg's in the clipboard, so it must be converted always. This more than likely won't keep any image metadata, but it's useful for quick sharing. Most chat applications scrub metadata nowadays anyways.

rvion commented 6 months ago

🔥 great PR @birdddev 🚀 !

Added a few comments;

As far as I can tell, you can only put png/jpg's

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/clipboard/clipboard_writer.cc;l=313;drc=e882b8e4a8272f65cb14c608d3d2bc4f0512aa20

Lol, indeed, by default, chrome only support those... BUT ! we can access any node API or node_module library from anyfile in the frontend (no restrictions, you can treat your onClick callbacks as if it was backend code)

so any lib like https://github.com/kufii/img-clipboard (that win/mac/linux X/wayland) could be used; (this lib is bad because it depends on extra libs liketemp-write, that we don't need, since MediaImageL always have a corresponding file on disk already; so we could simply just execute some command for each os to copy those in the clipboard)

(This is not a request at all; we can merge that branch as-is if you want, it's already an improvement over what we have)

rvion commented 6 months ago

Ah; and finally, just some random extra ideas; I had seeing that PR, that I'm noting down (not requests by any mean) :

rvion commented 6 months ago

🔥