Image-Py / imagepy

Image process framework based on plugin like imagej, it is esay to glue with scipy.ndimage, scikit-image, opencv, simpleitk, mayavi...and any libraries based on numpy
http://imagepy.org
BSD 4-Clause "Original" or "Old" License
1.3k stars 332 forks source link

Multi-OS screen capture utility #90

Closed CsatiZoltan closed 4 years ago

CsatiZoltan commented 4 years ago

The ImageGrab module cannot load under Linux:

Some plugin may be not loaded, but not affect others!
>>> menus/Plugins         screencap_plg.py    ImageGrab is macOS and Windows only

I recommend replacing it with the cross-platform and actively maintained pyscreenshot tool. The syntax would remain the same (see the Examples section of the previous link), so it's a drop-in replacement for ImageGrab. If you don't want more dependencies, just use (copied from here)

import wx
wx.App()  # Need to create an App instance before doing anything
screen = wx.ScreenDC()
size = screen.GetSize()
bmp = wx.EmptyBitmap(size[0], size[1])
mem = wx.MemoryDC(bmp)
mem.Blit(0, 0, size[0], size[1], screen, 0, 0)
del mem  # Release bitmap
bmp.SaveFile('screenshot.png', wx.BITMAP_TYPE_PNG)

I tried it and works on multi-monitor setups as well. The advantage is that there is no additional dependency as wxpython is already a requirement for ImagePy.

yxdragon commented 4 years ago

ok, now replace the snapshot by wx. and add a countdown parameter (if what we want is not the imagepy's window).

CsatiZoltan commented 4 years ago

Nice.