products ::: library ::: search ::: daily Python-URL!


Back   Next   


configure(options), config(options)

Change one or more configuration options.

cget(option) => string

Return the value of the given configuration option.

width() => integer, height() => integer

Returns the width (height) of the image, in pixels.

type() => string

Returns the string "photo".

get(x, y) => string

Fetch the pixel at the given position (where (0, 0) is in the upper left corner).

As of Python 1.5.2, this method returns a string containing one or three pixel components. Here's how to convert this string to either an integer or a 3-tuple of integers:

    optionvalue = im.get(x, y)
    if type(value) == type(""):
            value = int(value)
        except ValueError:
            value = tuple(map(int, string.split(value)))
put(data), put(data, bbox)

Write pixel data to the image.


Not supported in 1.5.2 or earlier.

write(filename, options)

Save the contents of the PhotoImage to a file using the given format. The following options can be used:

Table 36-1. PhotoImage Write Options






Specifies the format handler to use when writing this image. This is typically "gif" or "ppm".



Save only a part of the image. If a 2-tuple is given, write saves the rectangle between that position, and the lower right corner of the image. If a 4-tuple is given, it specifies which rectangle to save.


Clears the image. The size is left as it is, but the contents are made completely transparent.

copy() => photoimage object

Duplicate the current PhotoImage instance.

zoom(xscale, yscale), zoom(scale)

Resize the image to (xscale*width, yscale*height) pixels, using nearest neighbor resampling. In other words, each pixel in the source image will be expanded to xscale*yscale pixels. If only one scale is given, it is used for both directions.

subsample(xscale, yscale), subsample(scale)

Resize the image to (xscale/width, yscale/height) pixels, using nearest neighbor resampling. If only one scale is given, it is used for both directions.

Back   Next