Copy all images as PNG for universal clipboard compatibility
This commit is contained in:
parent
813ee58fd3
commit
f3152d138b
@ -1963,10 +1963,13 @@ class BooruApp(QMainWindow):
|
|||||||
import subprocess
|
import subprocess
|
||||||
try:
|
try:
|
||||||
if ext in _IMAGE_EXTS:
|
if ext in _IMAGE_EXTS:
|
||||||
_MIMES = {".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
# Convert to PNG for universal clipboard compat
|
||||||
".png": "image/png", ".gif": "image/gif", ".webp": "image/webp"}
|
from PIL import Image as _PIL
|
||||||
with open(path, "rb") as f:
|
import io as _io
|
||||||
subprocess.run(["wl-copy", "--type", _MIMES[ext]], stdin=f, timeout=10)
|
img = _PIL.open(path)
|
||||||
|
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