A
A
Amigun2019-04-15 09:14:03
Python
Amigun, 2019-04-15 09:14:03

How to specify the coordinates for creating screenshots in Python and the PIL library?

I have a code

from PIL import ImageGrab
screen = ImageGrab.grab()
screen.save('screenshot.png','PNG')

It works great, but saves a screenshot of the full screen
. And I need to save the screenshot only in the coordinates I specified. How to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
datka, 2019-04-15
@Amigun

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

A
asd111, 2019-04-15
@asd111

In addition to saws, there are also libraries for screenshots, try them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question