Python PIL | ImageGrab.grabclipboard() method

PIL is the Python Imaging Library which provides the python interpreter with image editing
capabilities. The ImageGrab module can be used to copy the contents of the screen or the clipboard to a PIL image memory.

PIL.ImageGrab.grabclipboard() method takes a snapshot of the clipboard image, if any.

Syntax: PIL.ImageGrab.grabclipboard()

Parameters: no arguments

Returns: On Windows, an image, a list of filenames, or None if the clipboard does not contain image data or filenames.



Note: This Module only work for Windows and Mac OS.

filter_none

edit
close

play_arrow

link
brightness_4
code

# Importing Image and ImageGrab module from PIL package 
from PIL import Image, ImageGrab
        
# using the grabclipboard method
im = ImageGrab.grabclipboard()
     
im.show()

chevron_right


Output:

After changing the image on the clipboard

filter_none

edit
close

play_arrow

link
brightness_4
code

# Importing Image and ImageGrab module from PIL package 
from PIL import Image, ImageGrab
        
# using the grabclipboard method
im = ImageGrab.grabclipboard()
     
im.show()

chevron_right


Output:

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : nidhi_biet

Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.