Taking screenshots with Python
Screenshots allow you to capture exactly what's on your screen to share with others or save for future purposes. Python provides different modules for capturing screenshots. Here, we will be looking at 3 modules that let you take screenshots.
Using pyscreenshot
Installation
pip install pyscreenshot
pip install Pillow
Usage
import pyscreenshot as ps
img = ps.grab()
img.save('screenshot1.png')
Using pyautogui
Installation
pip install pyautogui
Usage
import pyautogui
img = pyautogui.screenshot()
img.save('screenshot2.png')
Using Pillow
Installation
pip install Pillow
Usage
from PIL import ImageGrab
img = ImageGrab.grab(bbox=(0,0,900,900))
img.save('screenshot3.png')
If you would like to contribute to Hackzism you can also write an article and mail to hackzism.hack@gmail.com.
Your article will be published on our home page.
Comments
Post a Comment