The pyscreenshot module can be used to copy the contents of the screen to a PIL or Pillow image memory. Replacement for the ImageGrab Module, which works on Windows only. For handling image memory (e.g. saving to file, converting,..) please read PIL or Pillow documentation.


Travis Coveralls Latest Version Supported Python versions License Downloads Code Health Documentation

Pyscreenshot tries to allow to take screenshots without installing 3rd party libraries. It is cross-platform but useful for Linux based distributions. It is only a pure Python wrapper, a thin layer over existing back-ends. Its strategy should work on most Linux distributions: a lot of back-ends are wrapped, if at least one exists then it works, if not then one back-end should be installed. Performance and interactivity are not important for this library.
Known problems:
Similar projects:


grab and show the whole screen:

#-- include('examples/') --#
import pyscreenshot as ImageGrab

if __name__ == "__main__":
    # fullscreen

to start the example:

python -m pyscreenshot.examples.showgrabfullscreen

grab and show the part of the screen

#-- include('examples/')--#
import pyscreenshot as ImageGrab

if __name__ == "__main__":
    # part of the screen
    im=ImageGrab.grab(bbox=(10,10,510,510)) # X1,Y1,X2,Y2

to start the example:

python -m pyscreenshot.examples.showgrabbox



  • install pip

  • install PIL or Pillow

  • install at least one back-end

  • install the program:

    # as root
    pip install pyscreenshot

Ubuntu 14.04

sudo apt-get install python-pip
sudo apt-get install python-pil
sudo pip install pyscreenshot
# optional back-ends
sudo apt-get install scrot imagemagick python-gtk2 python-qt4 python-wxgtk2.8
# optional for examples
sudo pip install entrypoint2


# as root
pip uninstall pyscreenshot

Command line interface

Back-end performance:

The performance can be checked with pyscreenshot.check.speedtest.


#-- sh('python -m pyscreenshot.check.speedtest --virtual-display 2>/dev/null') --#

n=10   to_file: True   bounding box: None
wx                    1.3  sec        (  130 ms per call)
pygtk                 1    sec        (  100 ms per call)
pyqt                  1.1  sec        (  109 ms per call)
scrot                 0.71 sec        (   70 ms per call)
imagemagick           0.64 sec        (   64 ms per call)

n=10   to_file: False  bounding box: None
wx                    1.1  sec        (  109 ms per call)
pygtk                 1.3  sec        (  126 ms per call)
pyqt                  1.4  sec        (  135 ms per call)
scrot                 0.94 sec        (   94 ms per call)
imagemagick           0.78 sec        (   78 ms per call)

n=10   to_file: False  bounding box: (10, 10, 20, 20)
wx                    1    sec        (  101 ms per call)
pygtk                 0.62 sec        (   61 ms per call)
pyqt                  1.3  sec        (  127 ms per call)
scrot                 0.87 sec        (   87 ms per call)
imagemagick           0.58 sec        (   57 ms per call)

Print versions:

#-- sh('python -m pyscreenshot.check.versions 2> /dev/null ')--#
pyscreenshot         0.3.4
pygtk                2.28.6
pyqt                 not implemented
scrot                0.8
imagemagick          6.7.7

command line help

#-- sh('python -m pyscreenshot.check.speedtest --help')--#
usage: [-h] [-v] [--debug]

optional arguments:
  -h, --help            show this help message and exit
  -v, --virtual-display
  --debug               set logging level to DEBUG
#-- sh('python -m pyscreenshot.check.versions --help')--#
usage: [-h] [--debug]

optional arguments:
  -h, --help  show this help message and exit
  --debug     set logging level to DEBUG


digraph G {
     node [fontsize=8];

     subgraph cluster_0 {
             label = "pyscreenshot";
             subgraph cluster_1 {
                     label = "API";

             subgraph cluster_2 {
                     label = "plugins";

                     pyscreenshot -> GtkPixbufWrapper;
                     pyscreenshot -> QtGrabWindowWrapper;
                     pyscreenshot -> PilWrapper;
                     pyscreenshot -> ImagemagickWrapper;
                     pyscreenshot -> WxScreenWrapper;
      pyscreenshot -> ScrotWrapper;
      pyscreenshot -> MacQuartzWrapper
      pyscreenshot -> ScreencaptureWrapper
     QtGrabWindowWrapper -> PyQt -> Qt;
     PilWrapper -> PIL -> Windows;
     ImagemagickWrapper -> Imagemagick -> X11;
     ScrotWrapper -> Scrot -> X11;

     GtkPixbufWrapper -> PyGTK -> "GTK+";
     WxScreenWrapper -> wxPython -> wxWidgets;
     wxWidgets -> "GTK+";
     wxWidgets -> MacOS;
     wxWidgets -> Windows;
     wxWidgets -> X11;

MacQuartzWrapper -> Quartz -> MacOS;
ScreencaptureWrapper -> screencapture -> MacOS;

     application -> pyscreenshot;



pyscreenshot.backend_version(backend, childprocess=True)[source]

Back-end version

  • backend – back-end (examples:scrot, wx,..)
  • childprocess – see grab()

version as string


Back-end names as a list

Returns:back-ends as string list
pyscreenshot.grab(bbox=None, childprocess=True, backend=None)[source]

Copy the contents of the screen to PIL image memory.

  • bbox – optional bounding box (x1,y1,x2,y2)
  • childprocess – pyscreenshot can cause an error, if it is used on more different virtual displays and back-end is not in different process. Some back-ends are always different processes: scrot, imagemagick
  • backend – back-end can be forced if set (examples:scrot, wx,..), otherwise back-end is automatic
pyscreenshot.grab_to_file(filename, childprocess=True, backend=None)[source]

Copy the contents of the screen to a file.

  • filename – file for saving
  • childprocess – see grab()
  • backend – see grab()