The Most Simplest Way to Python Get Screenshot with ImageIO – Python Tutorial

By | November 4, 2019

There are some ways to help us to get computer screenshot, for example, you can use python pillow library to grab a screenshot.

Python Take Screenshot with Pillow: A Complete Guide for Beginners – Python Pillow Tutorial

However, in this tutorial, we will introduce a much simpler way to grab screenshot.

Import library

import imageio

In this example, we will use python imageio library to take this screenshot.

Get screenshot image data

im_screen = imageio.imread('<screen>')

You only need use one statement to get the screenshot image data.

Save screenshot image data into an image file.

After we have got screenshot image data, we should save it into a file. You also only need a statement to do it.

imageio.imwrite('demo-screenshot.png', im_screen)

In this example, we save screenshot image data to a png file. It may look like:

python take screenshot with imageio

To understand imageio.imwrite() you can read this tutorial.

Understand imageio.mimwrite() with Examples for Beginners- ImageIO Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *