Skip to content
Open
Changes from all commits
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
15 changes: 6 additions & 9 deletions pyscreeze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,15 @@ def _screenshot_linux(imageFilename=None, region=None):
# need to save an image file to disk.
im = ImageGrab.grab() # use Pillow's grab() for Pillow 9.2.0 and later.

if imageFilename is not None:
im.save(imageFilename)

if region is None:
# Return the full screenshot.
return im
else:
# Return just a region of the screenshot.
if region is not None:
# Crop image to region
assert len(region) == 4, 'region argument must be a tuple of four ints' # TODO fix this
region = [int(x) for x in region]
im = im.crop((region[0], region[1], region[2] + region[0], region[3] + region[1]))
return im
if imageFilename is not None:
im.save(imageFilename)
# Return the screenshot.
return im
elif RUNNING_X11 and SCROT_EXISTS: # scrot only runs on X11, not on Wayland.
# Even if gnome-screenshot exists, use scrot on X11 because gnome-screenshot
# has this annoying screen flash effect that you can't disable, but scrot does not.
Expand Down