Accueil
Rechercher:
sur developpez.com sur les forums
Forums | Tutoriels | F.A.Q's | Participez | Hébergement | Contacts
Accueil Conception Java DotNET Visual Basic  C  C++ Delphi MS-Office SQL & SGBD Oracle  4D  Business Intelligence
Club Emploi Blogs   TV   Dév. Web PHP XML Python Autres 2D-3D-Jeux Sécurité Windows Linux PC Mac
FORUM PYTHON F.A.Q PYTHON TUTORIELS PYTHON SOURCES PYTHON OUTILS PYTHON LIVRES PYTHON
The ImageGrab Module
Python Imaging Library Handbook

Prev   Next

The ImageGrab Module

The ImageGrab module can be used to copy the contents of the screen or the clipboard to a PIL image memory.

The current version works on Windows only.

Functions

grab

ImageGrab.grab() => image

ImageGrab.grab(bbox) => image

(New in 1.1.3) Take a snapshot of the screen, and return an "RGB" image. The bounding box argument can be used to copy only a part of the screen.

grabclipboard

ImageGrab.grabclipboard() => image or list of strings or None

(New in 1.1.4) Take a snapshot of the clipboard contents, and return an image object or a list of file names. If the clipboard doesn't contain image data, this function returns None.

You can use isinstance to check if the function returned a valid image object, or something else:

im = ImageGrab.grabclipboard()

if isinstance(im, Image.Image):
    ... got an image ...
elif im:
   for filename in im:
       try:
           im = Image.open(filename)
       except IOError:
           pass # ignore this file
       else:
           ... got an image ...
else:
    ... clipboard empty ...
Responsable bénévole de la rubrique Python : Guillaume Duriaud - Contacter par EMail :
Vos questions techniques : forum d'entraide Python - Publiez vos articles, tutoriels et cours
et rejoignez-nous dans l'équipe de rédaction du club d'entraide des développeurs francophones
Nous contacter - Copyright © 2000-2008 www.developpez.com - Legal informations.