# Importing Image and ImageGrab module from PIL package from PIL import Image, ImageGrab # creating an image object im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG") # using the grab method im2 = ImageGrab.grab(bbox = None) im2.show()
Taking screenshots of specific size or taking screenshots from specific region
# Importing Image and ImageGrab module from PIL package from PIL import Image, ImageGrab # creating an image object im1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG") # using the grab method im2 = ImageGrab.grab(bbox =(0, 0, 300, 300)) im2.show()
Parameters: box – The crop rectangle, as a (left, upper, right, lower)-tuple.
References
https://www.geeksforgeeks.org/pyhton-pil-imagegrab-grab-method/
https://stackoverflow.com/questions/19697210/taking-screen-shots-of-specific-size
https://stackoverflow.com/questions/47337811/what-do-the-parameters-of-bbox-mean-in-pillow