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"):
args = ["wl-paste"]
output = subprocess.check_output(["wl-paste", "-l"]).decode()
mime_types = output.splitlines()
for image_type in ["image/gif", "image/png"]:
if image_type in mime_types:
args.extend(["-t", image_type])
clipboard_mimetypes = output.splitlines()
Image.preinit()
for mimetype in Image.MIME.values():
if mimetype in clipboard_mimetypes:
args.extend(["-t", mimetype])
break
elif shutil.which("xclip"):
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]