def Clip(self):
subprocess.call('SnippingTool.exe')
#ctypes.windll.user32.OpenClipboard(0)
#ClippedScreen=ctypes.windll.user32.GetClipboardData
#ClippedScreen=PIL.ImageGrab.grab(bbox=(10,10,500,500))
ClippedScreen = PIL.ImageGrab.grabclipboard()
self.savescreenshot(ClippedScreen)
ImageGrab.grabclipboard()
is failing with raise IOError("Unsupported BMP bitfields layout")
. Read in the net that this is a known issue. No idea how to fix this.
Next tried ctypes, that is failing with AttributeError: '_FuncPtr'
object has no attribute 'save'
bbox is working, but I have no idea of how to make the clipping area dynamic.
Whole screen grabbing is working fine
def Prntscrn(self):
WholeScreen=ImageGrab.grab()
self.savescreenshot(WholeScreen)
Any help would be great, the idea is to use Snipping Tool to clip the screen and then copy the image from clipboard to a variable and use the savescreenshot method to save it in a folder. Any help would be great.
Run on python==2.7 pillow==2.7.0
from PIL import ImageGrab, Image
im= ImageGrab.grabclipboard()
if isinstance(im, Image.Image):
im.save('tmp.jpg')
IOError: Unsupported BMP bitfields layout
Reproducible with Pilllow 2.8.0, 2.8.1, 2.8.2. Not reproducible with Pillow 2.6.0, 2.7.0 https://github.com/python-pillow/Pillow/issues/1293
sorry to notice that is was only work on windows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With