Home » Taking a screenshot using python

Taking a screenshot using python

by maxguy71

In this article we use Pyscreenshot to take a screenshot using python

Pyscreenshot tries to allow to take screenshots without installing 3rd party libraries. It is cross-platform. It is only a pure Python wrapper, a thin layer over existing back-ends.

You need to install the pillow package before installing pyscreenshot package.


pip install Pillow pyscreenshot


This is the easiest way of taking a screenshot using the pyscreenshot module.

The show() function displays the captured screenshot.

"Grab the whole screen"
import pyscreenshot as ImageGrab

# grab fullscreen
im = ImageGrab.grab()

# save image file

This will get a portion of the screen

You  pass the coordinates in the form of a tuple to the grab function.

import pyscreenshot as ImageGrab

if __name__ == '__main__':
    # grab fullscreen
    im = ImageGrab.grab(bbox=(100, 100, 800, 800))
    # save file
    # show image in default app





You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More