You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
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
No, you can't directly copy images as pyperclip only supports str, int, float, bool types currently.
Reference:
https://github.com/asweigart/pyperclip/blob/master/src/pyperclip/__init__.py#L111
The fact that copy does not support binary data seems at odds with official documentation:
https://pypi.org/project/pyclip/
"Cross-platform clipboard utilities supporting both binary and text data."
Maybe the docs should be updated?
With
xclip
it is possiblie to copy binary data:
xclip -o -selection clipbobard -t image/png
I will take a look in the other commands soon
With
xclip
it is possiblie to copy binary data:
xclip -o -selection clipbobard -t image/png
I will take a look in the other commands soon
Is this command for Linux?
https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Clipboard.html#Gtk.Clipboard.request_contents
https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Clipboard.html#Gtk.Clipboard.request_image
https://doc.qt.io/archives/qt-4.8/qclipboard.html#mimeData
https://doc.qt.io/archives/qt-4.8/qclipboard.html#image
With
xclip
it is possiblie to copy binary data:
xclip -o -selection clipbobard -t image/png
I will take a look in the other commands soon
Is this command for Linux?
If you need this behavior it's not hard to copy the function and set the target for
image/png
pyperclip/src/pyperclip/__init__.py
Line 215
781603e
def paste_xclip(primary=False, image=False):
selection = "c" # DEFAULT_SELECTION
if primary:
selection = "p" # PRIMARY_SELECTION
command = ["xclip", "-selection", selection, "-o"]
if image:
command += ["-t", "image/png"] # Pass mime as argument?
p = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True,
stdout, stderr = p.communicate()
# Intentionally ignore extraneous output on stderr when clipboard is empty
if not image:
return stdout.decode("utf-8")
else:
return stdout
def
send_to_clipboard
(
clip_type
,
data
):
win32clipboard
.
OpenClipboard
()
win32clipboard
.
EmptyClipboard
()
win32clipboard
.
SetClipboardData
(
clip_type
,
data
)
win32clipboard
.
CloseClipboard
()
filepath
=
"image.jpg"
image
=
Image
.
open
(
filepath
)
output
=
BytesIO
()
image
.
convert
(
"RGB"
).
save
(
output
,
"BMP"
)
data
=
output
.
getvalue
()[
14
:]
output
.
close
()
send_to_clipboard
(
win32clipboard
.
CF_DIB
,
data
)