Taking Screen shots of specific size

后端 未结 5 461
庸人自扰
庸人自扰 2021-01-03 03:26

What imaging modules for python will allow you to take a specific size screenshot (not whole screen)? I have tried PIL, but can\'t seem to make ImageGrab.grab() select a sma

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 04:13

    You can use pyscreenshot module.
    The pyscreenshot module can be used to copy the contents of the screen to a PIL image memory or file. You can install it using pip.

    $ sudo pip install pyscreenshot
    

    Usage:

    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')
    

提交回复
热议问题