相关文章推荐
仗义的自行车  ·  Connection refused to ...·  2 月前    · 
强健的单车  ·  Android: Exploring ...·  2 月前    · 
闷骚的弓箭  ·  mrguo·  3 月前    · 
逆袭的黑框眼镜  ·  JaversException ...·  6 月前    · 

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?

wl-paste -t <target>
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 )