Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

python screenshot

Project description

The ``pyscreenshot`` module can be used to copy
the contents of the screen to a PIL_ or Pillow_ image memory using various back-ends.
Replacement for the ImageGrab_ Module, which works on Windows only,
so Windows users don't need this library.
For handling image memory (e.g. saving to file, converting,..) please read PIL_ or Pillow_ documentation.

* home:
* documentation:

|Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |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.

* Cross-platform wrapper
* Capturing the whole desktop
* Capturing an area
* saving to PIL_ or Pillow_ image memory
* some back-ends are based on this discussion:
* pure Python library
* supported Python versions: 2.7, 3.4, 3.5, 3.6, 3.7
* It has wrappers for various back-ends:
* scrot_
* ImageMagick_
* PyGTK_
* PIL_ or Pillow_ (only on windows)
* PyQt4_
* PyQt5_
* PySide_
* wxPython_
* Quartz (Mac)
* screencapture (Mac)
* gnome-screenshot_
* time taken: 0.1s - 2.0s
* Performance is not a target for this library, but you can benchmark the back-ends and choose the fastest one.
* Interactivity is not supported.
* Mouse pointer is not visible.

Known problems:
* ImageMagick_ creates blackbox_ on some systems
* gnome-screenshot_ back-end does not check $DISPLAY -> not working with Xvfb

Similar projects:


grab and show the whole screen::

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

if __name__ == '__main__':

# grab fullscreen
im = ImageGrab.grab()

# save image file'screenshot.png')

# show image in a window

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 Pillow_ (Ubuntu: ``sudo apt-get install python-pil``)
* install at least one back-end
* install the program::

pip install pyscreenshot


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') --#

wx 3.4 sec ( 343 ms per call)
pygtk 5.6 sec ( 558 ms per call)
pygdk3 2.8 sec ( 275 ms per call)
pyqt 5.7 sec ( 565 ms per call)
pyqt5 5.3 sec ( 527 ms per call)
scrot 4.8 sec ( 481 ms per call)
imagemagick 7.5 sec ( 750 ms per call)
pyside 5.6 sec ( 558 ms per call)
gnome-screenshot 13 sec ( 1278 ms per call)

Print versions::

#-- sh('python -m pyscreenshot.check.versions 2> /dev/null ')--#
python 2.7.15rc1
pyscreenshot 0.4.2
pygtk 2.28.6
pygdk3 3.26.1
pyqt 4.12.1
pyqt5 5.10.1
scrot 0.8
imagemagick 6.9.7
pyside 1.2.2
gnome-screenshot 3.25.0


On Wayland only the `gnome-screenshot` back-end works::

im = ImageGrab.grab(backend='gnome-screenshot')

.. _pip:
.. _ImageGrab:
.. _PIL:
.. _Pillow:
.. _ImageMagick:
.. _PyGTK:
.. _blackbox:
.. _scrot:
.. _PyQt4:
.. _PyQt4:
.. _PySide:
.. _wxPython:
.. _gnome-screenshot:

.. |Travis| image::
.. |Coveralls| image::
.. |Latest Version| image::
.. |Supported Python versions| image::
.. |License| image::
.. |Code Health| image::
.. |Documentation| image::

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyscreenshot, version 0.5.1
Filename, size File type Python version Upload date Hashes
Filename, size pyscreenshot-0.5.1.tar.gz (16.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page