Use image/png mime type for ImageGrab (wl-paste) if possible, otherwise the first mime type taken

This commit is contained in:
rrcgat 2023-05-23 18:44:25 +08:00
parent c656583b84
commit fffcb558f6
No known key found for this signature in database
GPG Key ID: 8A5698D402519CF8

View File

@ -147,14 +147,11 @@ def grabclipboard():
clipboard_mimetypes = output.splitlines() clipboard_mimetypes = output.splitlines()
def find_mimetype(): def find_mimetype():
for mime in Image.MIME.values(): if "image/png" in clipboard_mimetypes:
if mime in clipboard_mimetypes: return "image/png"
return mime if clipboard_mimetypes:
return clipboard_mimetypes[0]
Image.preinit()
mimetype = find_mimetype()
if not mimetype:
Image.init()
mimetype = find_mimetype() mimetype = find_mimetype()
if mimetype: if mimetype:
args.extend(["-t", mimetype]) args.extend(["-t", mimetype])