The pyscreenshot
module can be used to copy
the contents of the screen to a PIL image memory or file.
Replacement for the ImageGrab Module, which works on Windows only.
- Links:
- home: https://github.com/ponty/pyscreenshot
- documentation: http://ponty.github.com/pyscreenshot
- 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
- saving to file or PIL image memory
- some back-ends are based on this discussion: http://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux
- pure Python library
- Known problems:
- not implemented: Capturing an active window
- different back-ends generate slightly different images from the same desktop, this should be investigated
- ImageMagick creates blackbox on some systems
- PyGTK back-end does not check $DISPLAY -> not working with Xvfb
- slow: 0.2s - 0.7s
- Similar projects:
Example:
import pyscreenshot as ImageGrab # fullscreen im=ImageGrab.grab() im.show() # part of the screen im=ImageGrab.grab(bbox=(10,10,500,500)) im.show() # to file ImageGrab.grab_to_file('im.png')
sudo apt-get install python-pip sudo pip install pyscreenshot sudo apt-get install python-imaging # optional back-ends sudo apt-get install scrot sudo apt-get install imagemagick sudo apt-get install python-gtk2 sudo apt-get install python-qt4 # optional for examples sudo pip install entrypoint2
# as root pip uninstall pyscreenshot