・ Mac Catalina -Python 3.8.1
If it is left as it is, the desktop will be taken even if the screenshot is taken, so Allows screen recording.
"System Preferences" → "Security & Privacy"
Check the terminal in "Screen recording".
Install pyautogui.
pip install pyautogui
You can take a full screen screenshot with pyautogui.screenshot ().
import pyautogui
screenshot = pyautogui.screenshot()
screenshot.save('screenshot.png')
By using region = (position from the left, position from the top, width, height), You can take a screenshot of a specific range.
import pyautogui
screenshot = pyautogui.screenshot(region = (100, 200, 1500, 875))
screenshot.save('screenshot.png')
By converting to RGB, you can save as JPEG.
screenshot = screenshot.convert('RGB')
Convert a large png file to a jpg file pyautogui
Recommended Posts