Update src/PIL/ImageGrab.py

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Carl Weaver 2023-04-16 15:37:38 +08:00 committed by GitHub
parent 099d696dc7
commit 6d12581385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,10 +136,11 @@ def grabclipboard():
if shutil.which("wl-paste"): if shutil.which("wl-paste"):
args = ["wl-paste"] args = ["wl-paste"]
output = subprocess.check_output(["wl-paste", "-l"]).decode() output = subprocess.check_output(["wl-paste", "-l"]).decode()
mime_types = output.splitlines() clipboard_mimetypes = output.splitlines()
for image_type in ["image/gif", "image/png"]: Image.preinit()
if image_type in mime_types: for mimetype in Image.MIME.values():
args.extend(["-t", image_type]) if mimetype in clipboard_mimetypes:
args.extend(["-t", mimetype])
break break
elif shutil.which("xclip"): elif shutil.which("xclip"):
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"] args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]