mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Merge pull request #7094 from rrcgat/fix-imagegrab-with-wl-paste
This commit is contained in:
commit
d4b7cfa647
|
@ -22,7 +22,8 @@ set -e
|
||||||
if [[ $(uname) != CYGWIN* ]]; then
|
if [[ $(uname) != CYGWIN* ]]; then
|
||||||
sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\
|
sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\
|
||||||
ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\
|
ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\
|
||||||
cmake meson imagemagick libharfbuzz-dev libfribidi-dev
|
cmake meson imagemagick libharfbuzz-dev libfribidi-dev\
|
||||||
|
sway wl-clipboard
|
||||||
fi
|
fi
|
||||||
|
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
@ -84,7 +84,9 @@ jobs:
|
||||||
python3 -m pip install pytest-reverse
|
python3 -m pip install pytest-reverse
|
||||||
fi
|
fi
|
||||||
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
|
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
|
||||||
xvfb-run -s '-screen 0 1024x768x24' .ci/test.sh
|
xvfb-run -s '-screen 0 1024x768x24' sway&
|
||||||
|
export WAYLAND_DISPLAY=wayland-1
|
||||||
|
.ci/test.sh
|
||||||
else
|
else
|
||||||
.ci/test.sh
|
.ci/test.sh
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -98,3 +98,18 @@ $ms = new-object System.IO.MemoryStream(, $bytes)
|
||||||
|
|
||||||
im = ImageGrab.grabclipboard()
|
im = ImageGrab.grabclipboard()
|
||||||
assert_image_equal_tofile(im, "Tests/images/hopper.png")
|
assert_image_equal_tofile(im, "Tests/images/hopper.png")
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
(
|
||||||
|
sys.platform != "linux"
|
||||||
|
or not all(shutil.which(cmd) for cmd in ("wl-paste", "wl-copy"))
|
||||||
|
),
|
||||||
|
reason="Linux with wl-clipboard only",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize("ext", ("gif", "png", "ico"))
|
||||||
|
def test_grabclipboard_wl_clipboard(self, ext):
|
||||||
|
image_path = "Tests/images/hopper." + ext
|
||||||
|
with open(image_path, "rb") as fp:
|
||||||
|
subprocess.call(["wl-copy"], stdin=fp)
|
||||||
|
im = ImageGrab.grabclipboard()
|
||||||
|
assert_image_equal_tofile(im, image_path)
|
||||||
|
|
|
@ -142,7 +142,18 @@ def grabclipboard():
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if shutil.which("wl-paste"):
|
if shutil.which("wl-paste"):
|
||||||
|
output = subprocess.check_output(["wl-paste", "-l"]).decode()
|
||||||
|
mimetypes = output.splitlines()
|
||||||
|
if "image/png" in mimetypes:
|
||||||
|
mimetype = "image/png"
|
||||||
|
elif mimetypes:
|
||||||
|
mimetype = mimetypes[0]
|
||||||
|
else:
|
||||||
|
mimetype = None
|
||||||
|
|
||||||
args = ["wl-paste"]
|
args = ["wl-paste"]
|
||||||
|
if mimetype:
|
||||||
|
args.extend(["-t", mimetype])
|
||||||
elif shutil.which("xclip"):
|
elif shutil.which("xclip"):
|
||||||
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]
|
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user