Skip to main content

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.

Links:

Travis Coveralls Latest Version Supported Python versions License Documentation

Goal:

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.

Features:
Known problems:
Similar projects:

Examples

grab and show the whole screen:

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

if __name__ == '__main__':

    # grab fullscreen
    im = ImageGrab.grab()

    # save image file
    im.save('screenshot.png')

    # show image in a window
    im.show()
#-#

to start the example:

python -m pyscreenshot.examples.showgrabfullscreen

grab and show the part of the screen:

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

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

to start the example:

python -m pyscreenshot.examples.showgrabbox

Installation

  • install pip

  • install Pillow (Ubuntu: sudo apt-get install python-pil)

  • install at least one back-end

  • install the program:

    pip install pyscreenshot

Uninstall:

pip uninstall pyscreenshot

Command line interface

Back-end performance:

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

Example:

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

n=10
------------------------------------------------------
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
wx                   3.0.2.0
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
#-#

Wayland

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

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

Project details


Download files

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

Source Distribution

pyscreenshot-0.6.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyscreenshot-0.6-py2.py3-none-any.whl (23.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyscreenshot-0.6.tar.gz.

File metadata

  • Download URL: pyscreenshot-0.6.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.17

File hashes

Hashes for pyscreenshot-0.6.tar.gz
Algorithm Hash digest
SHA256 7322ad9454652b1702a3689646ce53ef01ed2b14869ea557030bd4e03a06fc0e
MD5 e33b6e98c6b79cb35f78bd77d99aa0c5
BLAKE2b-256 0818f7ab01b3b60550a89c1dd74d6f7c8347ad8cc20a0f1f9bfad7079893c931

See more details on using hashes here.

File details

Details for the file pyscreenshot-0.6-py2.py3-none-any.whl.

File metadata

  • Download URL: pyscreenshot-0.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.17

File hashes

Hashes for pyscreenshot-0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1af20739c754f7fa1e7f792c0c682fd89e30c9db4004252792830cc538727235
MD5 696f56c1d187100edbd61ea08028f430
BLAKE2b-256 fe2750ab425789118be0ea390cf2b5e6dc65bafe2b5a9a2efb1db8426836124b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page