-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paste Image From Clipboard #735
Comments
It would really slick if we could a user could paste an image from the clipboard using CTRL-V / CMD-V. However, this would require us to have the concept of an image component being "in focus". |
I could not find an example of this in the web since then, WDYT about this currently @abidlabs, @dawoodkhan82, @pngwn, @gary149? Shall we put effort in this? Using the image component would be much more easier via this. |
I use it all the time in Slack but I agree with @abidlabs that having no element being in focus like in Slack makes it hard. Also not a fan of hijacking the "select a file". Having a visible paste button icon that you need to click (on the image component) could be a solution but will probably be confusing to users so I'm not sure it's worth the effort of implementing. |
Yeah it's not going to be easily possible with the way that the UI components are currently laid out. We'd have to develop a way to "focus" on a particular component, so it would have to involve a UI/UX redesign. It's a nice idea, but IMO too costly to implement |
Ok then, instead of closing this issue I would like to remove the milestone and keep it in low priority. |
This is exactly the way, @gary149! Providing an unobtrusive option to paste from the clipboard into the Image component would go a long way in terms of streamlining the workflow process without impeding user experience since drag-n-drop and file select interface will not suffer from a small icon at the corner. The idea with focusable elements will never work here in my opinion because the design goal of Gradio is different from something like Slack. In a messenger there is only one primary element — message box — so it makes sense to direct all user's input there. In a Gradio app we can have a dozen Image components on the page, it makes no sense hitting tab between them to focus on the right one when the intuitive thing to do is just click/tap on the button. Plus as mentioned "focusable" components are costly to implement. I'd very much like to see "paste from clipboard" icon implemented 🙏 |
Could you do it the same way in html5 via javascript similar to URL parameter functions within gradio? I notice there you have window.location referenced and the JS portions run as functions within the DOM as shown here: https://huggingface.co/spaces/awacke1/Web-URL-HTTP-Parameters-Get-Set. Here is the DOM based code to handle the image paste: document.addEventListener('paste', function (evt) {
}); --Aaron |
From some discussions on the huggingface discord, I'd like to continue the feature request here. My proposal would be to add a button to the image component similar to the existing text box copy-to-clipboard button, but instead an optional copy-from-clipboard button which you could add in the same fashion. Buttons seem to be the most reliable option browser-to-browser, and this requires a relatively minimal engineering investment to add. Cheers, |
Want this so much! I'd even be happy with a hacky solution. Getting more agility when moving images around an image-centric gradio interface like Automatic1111's webui would cut out so many steps in a lot of advanced workflows. |
Sharing my hacky solution for @MakingMadness : I've been using pyclip to get the image from clipboard. The trick is that gradio is using bgr and cv2 is using rgb or something like that so I ended up reconverting the images several times otherwise blue are turned to yellow etc. The function get_image is called by a button click that takes as input the gallery and outputs to the gallery. Let me know if something's not clear:
|
This is now supported in the new |
@abidlabs is it planned to add |
Is your feature request related to a problem? Please describe.
I think uploading images from the clipboard could make uploading images from web much more easier.
I used these kind of components before as a user and it was a nice UX. I will share it here if I can find an example
When you click select a file you either paste from clipboard or select a file from your computer.
The text was updated successfully, but these errors were encountered: