Robust multi-monitor screenshot grabber (Windows-only right now)
Project description
Desktopmagic
============
Desktopmagic takes screenshots on Windows. It supports any
arrangement of multiple monitors, and does not leak memory in any
failure mode (locked workstation, no monitor attached, etc). If you wish,
it can be used continuously to take millions of screenshots.
You may want this instead of PIL's ImageGrab because:
* Desktopmagic can take a screenshot of all monitors. You can:
* Take a screenshot of the entire virtual screen.
* Take a screenshot of the entire virtual screen, split into separate PIL Images.
* Take a screenshot of just one display.
* Take a screenshot of an arbitrary region of the virtual screen.
(See below for usage)
* PIL leaks memory if you try to take a screenshot when the
workstation is locked (as of 2011-01).
Requirements
============
* pywin32: http://sourceforge.net/projects/pywin32/files/pywin32/
* PIL: http://www.pythonware.com/products/pil/ - unless you don't need
`getScreenAsImage`, `getDisplaysAsImages`, or `getRectAsImage`.
Installation
============
```
pip install Desktopmagic
```
or:
```
git clone https://github.com/ludios/Desktopmagic
cd Desktopmagic
pip install .
```
or without pip:
```
python setup.py install
```
This installs the module `desktopmagic` and the script `screengrab_torture_test`.
Examples
========
```py
from desktopmagic.screengrab_win32 import (
getDisplayRects, saveScreenToBmp, saveRectToBmp, getScreenAsImage,
getRectAsImage, getDisplaysAsImages)
# Save the entire virtual screen as a BMP (no PIL required)
saveScreenToBmp('screencapture_entire.bmp')
# Save an arbitrary rectangle of the virtual screen as a BMP (no PIL required)
saveRectToBmp('screencapture_256_256.bmp', rect=(0, 0, 256, 256))
# Save the entire virtual screen as a PNG
entireScreen = getScreenAsImage()
entireScreen.save('screencapture_entire.png', format='png')
# Get bounding rectangles for all displays, in display order
print "Display rects are:", getDisplayRects()
# -> something like [(0, 0, 1280, 1024), (-1280, 0, 0, 1024), (1280, -176, 3200, 1024)]
# Capture an arbitrary rectangle of the virtual screen: (left, top, right, bottom)
rect256 = getRectAsImage((0, 0, 256, 256))
rect256.save('screencapture_256_256.png', format='png')
# Unsynchronized capture, one display at a time.
# If you need all displays, use getDisplaysAsImages() instead.
for displayNumber, rect in enumerate(getDisplayRects(), 1):
imDisplay = getRectAsImage(rect)
imDisplay.save('screencapture_unsync_display_%d.png' % (displayNumber,), format='png')
# Synchronized capture, entire virtual screen at once, cropped to one Image per display.
for displayNumber, im in enumerate(getDisplaysAsImages(), 1):
im.save('screencapture_sync_display_%d.png' % (displayNumber,), format='png')
```
For more information, see the docstrings in https://github.com/ludios/Desktopmagic/blob/master/desktopmagic/screengrab_win32.py
Wishlist
========
* OS X support
* Linux support
* Python 3 support (it probably almost works and just needs testing. But which <a href="http://stackoverflow.com/questions/3896286/image-library-for-python-3">PIL for Python 3</a>?)
Contributing
============
Patches and pull requests are welcome.
This coding standard applies: http://ludios.org/coding-standard/
============
Desktopmagic takes screenshots on Windows. It supports any
arrangement of multiple monitors, and does not leak memory in any
failure mode (locked workstation, no monitor attached, etc). If you wish,
it can be used continuously to take millions of screenshots.
You may want this instead of PIL's ImageGrab because:
* Desktopmagic can take a screenshot of all monitors. You can:
* Take a screenshot of the entire virtual screen.
* Take a screenshot of the entire virtual screen, split into separate PIL Images.
* Take a screenshot of just one display.
* Take a screenshot of an arbitrary region of the virtual screen.
(See below for usage)
* PIL leaks memory if you try to take a screenshot when the
workstation is locked (as of 2011-01).
Requirements
============
* pywin32: http://sourceforge.net/projects/pywin32/files/pywin32/
* PIL: http://www.pythonware.com/products/pil/ - unless you don't need
`getScreenAsImage`, `getDisplaysAsImages`, or `getRectAsImage`.
Installation
============
```
pip install Desktopmagic
```
or:
```
git clone https://github.com/ludios/Desktopmagic
cd Desktopmagic
pip install .
```
or without pip:
```
python setup.py install
```
This installs the module `desktopmagic` and the script `screengrab_torture_test`.
Examples
========
```py
from desktopmagic.screengrab_win32 import (
getDisplayRects, saveScreenToBmp, saveRectToBmp, getScreenAsImage,
getRectAsImage, getDisplaysAsImages)
# Save the entire virtual screen as a BMP (no PIL required)
saveScreenToBmp('screencapture_entire.bmp')
# Save an arbitrary rectangle of the virtual screen as a BMP (no PIL required)
saveRectToBmp('screencapture_256_256.bmp', rect=(0, 0, 256, 256))
# Save the entire virtual screen as a PNG
entireScreen = getScreenAsImage()
entireScreen.save('screencapture_entire.png', format='png')
# Get bounding rectangles for all displays, in display order
print "Display rects are:", getDisplayRects()
# -> something like [(0, 0, 1280, 1024), (-1280, 0, 0, 1024), (1280, -176, 3200, 1024)]
# Capture an arbitrary rectangle of the virtual screen: (left, top, right, bottom)
rect256 = getRectAsImage((0, 0, 256, 256))
rect256.save('screencapture_256_256.png', format='png')
# Unsynchronized capture, one display at a time.
# If you need all displays, use getDisplaysAsImages() instead.
for displayNumber, rect in enumerate(getDisplayRects(), 1):
imDisplay = getRectAsImage(rect)
imDisplay.save('screencapture_unsync_display_%d.png' % (displayNumber,), format='png')
# Synchronized capture, entire virtual screen at once, cropped to one Image per display.
for displayNumber, im in enumerate(getDisplaysAsImages(), 1):
im.save('screencapture_sync_display_%d.png' % (displayNumber,), format='png')
```
For more information, see the docstrings in https://github.com/ludios/Desktopmagic/blob/master/desktopmagic/screengrab_win32.py
Wishlist
========
* OS X support
* Linux support
* Python 3 support (it probably almost works and just needs testing. But which <a href="http://stackoverflow.com/questions/3896286/image-library-for-python-3">PIL for Python 3</a>?)
Contributing
============
Patches and pull requests are welcome.
This coding standard applies: http://ludios.org/coding-standard/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Desktopmagic-13.3.29.zip
(12.1 kB
view details)
Desktopmagic-13.3.29.tar.gz
(8.7 kB
view details)
File details
Details for the file Desktopmagic-13.3.29.zip
.
File metadata
- Download URL: Desktopmagic-13.3.29.zip
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27f51f0133abdd3d759e66cfb8cf65bef9e0f99db6b7f6125deb7699bffe6f53 |
|
MD5 | 94f25f89670df11cce0cd8812c965101 |
|
BLAKE2b-256 | 5274fe3f7949bae27d3a2228aec7079b9699db9d261a419348a6e8c1ce0527a9 |
File details
Details for the file Desktopmagic-13.3.29.tar.gz
.
File metadata
- Download URL: Desktopmagic-13.3.29.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a53913212e3228616a61765d43d746013aedfd6a7f528b17bbe233a57b292469 |
|
MD5 | e967410d2448a3934cda2ac1e5be2e17 |
|
BLAKE2b-256 | cffb376aa74160894863c040fb421ca6395f7502269aa71ad124bc65dc9f4b07 |