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.
- Links:
documentation: http://pyscreenshot.readthedocs.org
- 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. Performance and interactivity are not important for this library.
- Features:
Cross-platform wrapper
Capturing the whole desktop
Capturing an area
some back-ends are based on this discussion: http://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux
pure Python library
supported python versions: 2.6, 2.7, 3.3, 3.4, 3.5
time: 0.1s - 1.0s
- Known problems:
ImageMagick creates blackbox on some systems
PyGTK back-end does not check $DISPLAY -> not working with Xvfb
- Similar projects:
Examples
grab and show the whole screen:
#-- include('examples/showgrabfullscreen.py') --#
import pyscreenshot as ImageGrab
if __name__ == "__main__":
# fullscreen
im=ImageGrab.grab()
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
General
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
Uninstall
# as root 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 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
wx 2.8.12.1
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: speedtest.py [-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: versions.py [-h] [--debug]
optional arguments:
-h, --help show this help message and exit
--debug set logging level to DEBUG
#-#
Metadata
Release files for pyscreenshot 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyscreenshot-0.4.1.tar.gz | 14.3 kB | Without provenance | Details for pyscreenshot-0.4.1.tar.gz |
Release files / pyscreenshot-0.4.1.tar.gz
| Download URL | pyscreenshot-0.4.1.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddf2f5acdd6820046b6e8f53aebac7207d7ff193b0c4a3ca422d80c86693f473
|
|
BLAKE2b-256 checksum How to use checksums |
1e42676685693cfcd6e711dfc3965bac6064443602bef58d21a5b6ea1cbe1aac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyscreenshot 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.