Tuesday, November 19, 2024
Google search engine
HomeLanguagesPython PIL | ImageGrab.grabclipboard() method

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.




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


Output:

After changing the image on the clipboard




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


Output:

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments