Search on blog:

Python: How to get screenshot with pyscreenshot

Not all modules can works on Linux.

This module works on different systems and may use different programs.

On Linux it may use external programs like scrot, gnome-screenshot, imagemagick

import pyscreenshot as ImageGrab

print(ImageGrab.backends())

# fullscreen
im = ImageGrab.grab(backend='scrot')

# to file
im.save('im.png')

# directly to file
ImageGrab.grab_to_file('im.png', backend='gnome-screenshot')

List of all backends: 'pil', 'mss', 'scrot', 'maim', 'imagemagick', 'qtpy', 'pyqt5', 'pyqt', 'pyside2', 'pyside', 'wx', 'pygdk3', 'pygtk', 'm ac_screencapture', 'mac_quartz', 'gnome_dbus', 'gnome-screenshot', 'kwin_dbus'

If you like it
Buy a Coffee