Skip to content

Commit

Permalink
Use image/png mime type for ImageGrab (wl-paste) if possible, otherwi…
Browse files Browse the repository at this point in the history
…se the first mime type taken
  • Loading branch information
rrcgat committed May 23, 2023
1 parent c656583 commit fffcb55
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,12 @@ def grabclipboard():
clipboard_mimetypes = output.splitlines()

def find_mimetype():
for mime in Image.MIME.values():
if mime in clipboard_mimetypes:
return mime
if "image/png" in clipboard_mimetypes:
return "image/png"
if clipboard_mimetypes:
return clipboard_mimetypes[0]

Image.preinit()
mimetype = find_mimetype()
if not mimetype:
Image.init()
mimetype = find_mimetype()
if mimetype:
args.extend(["-t", mimetype])
elif shutil.which("xclip"):
Expand Down

0 comments on commit fffcb55

Please sign in to comment.