







The PIL.ImageTk Module

The ImageTk module contains support to create and modify
Tkinter 
BitmapImage and PhotoImage objects.

For examples, see the demo programs in the 
Scripts
directory.
Module Contents


BitmapImage(image=None, **options) (class) [ #PIL.ImageTk.BitmapImage-class# ]

Create a Tkinter-compatible bitmap image.

For more information about this class, see #PIL.ImageTk.BitmapImage-classThe BitmapImage Class .


getimage(photo)  [ #PIL.ImageTk.getimage-function# ]

Copies the contents of a PhotoImage to a PIL image memory.


PhotoImage(image=None, size=None, **options) (class) [ #PIL.ImageTk.PhotoImage-class# ]

Creates a Tkinter-compatible photo image.

For more information about this class, see #PIL.ImageTk.PhotoImage-classThe PhotoImage Class .



The BitmapImage Class 


BitmapImage(image=None, **options) (class) [ #PIL.ImageTk.BitmapImage-class# ]

Create a Tkinter-compatible bitmap image.  This can be used
everywhere Tkinter expects an image object.


__init__(image=None, **options)  [ #PIL.ImageTk.BitmapImage.__init__-method# ]

Create a Tkinter-compatible bitmap image.

The given image must have mode "1".  Pixels having value 0 are
treated as transparent.  Options, if any, are passed on to
Tkinter.  The most commonly used option is 
foreground,
which is used to specify the colour for the non-transparent
parts.  See the Tkinter documentation for information on how to
specify colours.


image

A PIL image.



__str__()  [ #PIL.ImageTk.BitmapImage.__str__-method# ]

Get the Tkinter bitmap image identifier.  This method is
automatically called by Tkinter whenever a BitmapImage object
is passed to a Tkinter method.


Returns:

A Tkinter bitmap image identifier (a string).



height()  [ #PIL.ImageTk.BitmapImage.height-method# ]

Get the height of the image.


Returns:

The height, in pixels.



width()  [ #PIL.ImageTk.BitmapImage.width-method# ]

Get the width of the image.


Returns:

The width, in pixels.




The PhotoImage Class 


PhotoImage(image=None, size=None, **options) (class) [ #PIL.ImageTk.PhotoImage-class# ]

Creates a Tkinter-compatible photo image.  This can be used
everywhere Tkinter expects an image object.  If the image is an RGBA
image, pixels having alpha 0 are treated as transparent.


__init__(image=None, size=None, **options)  [ #PIL.ImageTk.PhotoImage.__init__-method# ]

Create a photo image object. The constructor takes either
a PIL image, or a mode and a size.  Alternatively, you can
use the 
file or data options to initialize
the photo image object.


image

Either a PIL image, or a mode string.  If a
   mode string is used, a size must also be given.

size

If the first argument is a mode string, this
   defines the size of the image.

file=

A filename to load the image from (using
   Image.open(file)).

data=

An 8-bit string containing image data (as
   loaded from an image file).



__str__()  [ #PIL.ImageTk.PhotoImage.__str__-method# ]

Get the Tkinter photo image identifier.  This method is
automatically called by Tkinter whenever a PhotoImage object is
passed to a Tkinter method.


Returns:

A Tkinter photo image identifier (a string).



height()  [ #PIL.ImageTk.PhotoImage.height-method# ]

Get the height of the image.


Returns:

The height, in pixels.



paste(im, box=None)  [ #PIL.ImageTk.PhotoImage.paste-method# ]

Paste a PIL image into the photo image.  Note that this can
be very slow if the photo image is displayed.


im

A PIL image.  The size must match the target region.
   If the mode does not match, the image is converted to the
   mode of the bitmap image.

box

A 4-tuple defining the left, upper, right, and
   lower pixel coordinate.  If None is given instead of a
   tuple, all of the image is assumed.



width()  [ #PIL.ImageTk.PhotoImage.width-method# ]

Get the width of the image.


Returns:

The width, in pixels.





