Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer screenshots using XCB over gnome-screenshot #7143

Merged
merged 3 commits into from
May 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only check for gnome-screenshot on Linux
Co-authored-by: Ondrej Baranovič <3819630+nulano@users.noreply.github.com>
  • Loading branch information
radarhere and nulano authored May 10, 2023
commit 3ec03c6720e4a4a0d4bd5a893ccac6b1df14418a
6 changes: 5 additions & 1 deletion src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def grab(bbox=None, include_layered_windows=False, all_screens=False, xdisplay=N
im = im.crop(bbox)
return im
except OSError:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original error in #6312 was:

builtins.OSError: X get_image failed: error 8 (73, 0, 1315)

if xdisplay is None and shutil.which("gnome-screenshot"):
if (
xdisplay is None
and sys.platform not in ("darwin", "win32")
and shutil.which("gnome-screenshot")
):
fh, filepath = tempfile.mkstemp(".png")
os.close(fh)
subprocess.call(["gnome-screenshot", "-f", filepath])
Expand Down