Revert to native MIME types for clipboard copy
This commit is contained in:
parent
f3152d138b
commit
5c53ee7e87
@ -1963,13 +1963,10 @@ class BooruApp(QMainWindow):
|
|||||||
import subprocess
|
import subprocess
|
||||||
try:
|
try:
|
||||||
if ext in _IMAGE_EXTS:
|
if ext in _IMAGE_EXTS:
|
||||||
# Convert to PNG for universal clipboard compat
|
_MIMES = {".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
||||||
from PIL import Image as _PIL
|
".png": "image/png", ".gif": "image/gif", ".webp": "image/webp"}
|
||||||
import io as _io
|
with open(path, "rb") as f:
|
||||||
img = _PIL.open(path)
|
subprocess.run(["wl-copy", "--type", _MIMES[ext]], stdin=f, timeout=10)
|
||||||
buf = _io.BytesIO()
|
|
||||||
img.save(buf, "PNG")
|
|
||||||
subprocess.run(["wl-copy", "--type", "image/png"], input=buf.getvalue(), timeout=10)
|
|
||||||
else:
|
else:
|
||||||
# Videos/other: copy as file URI
|
# Videos/other: copy as file URI
|
||||||
uri = f"file://{Path(path).resolve()}"
|
uri = f"file://{Path(path).resolve()}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user