The picture Module

The Picture class and helper functions. This currently supports the following formats: JPEG, BMP, GIF, TIFF, IM, MSP, PNG, PCX, and PPM.

class picture.Picture(w=None, h=None, col=Color(255, 255, 255), image=None, filename=None)

A Picture class as a wrapper for PIL’s Image class.

add_line(col, x1, y1, x2, y2, width=1)

Draw a line of Color col and width width from (x1, y1) to (x2, y2) on this Picture.

add_oval(col, x, y, w, h)

Draw an empty oval of Color col, width w, and height h on this Picture. The upper left corner of the oval is at (x, y).

add_oval_filled(col, x, y, w, h)

Draw a filled oval of Color col, width w, and height h on this Picture. The upper left corner of the oval is at (x, y).

add_polygon(col, point_list)

Draw an empty polygon of Color col with corners for every vertex in list point_list on this Picture.

Note: point_list is a list containing vertices xy coordinates (ex. [x1,y1,x2,y2,x3,y3]) It should contain at least three coordinate pairs.

add_polygon_filled(col, point_list)

Draw a filled polygon of Color col with corners for every vertex in list point_list on this Picture.

Note: point_list is a list containing vertices xy coordinates (ex. [x1,y1,x2,y2,x3,y3]) It should contain at least three coordinate pairs.

add_rect(col, x, y, w, h)

Draw an empty rectangle of Color col, width w, and height h on this Picture. The upper left corner of the rectangle is at (x, y).

add_rect_filled(col, x, y, w, h)

Draw a filled rectangle of Color col, width w, and height h on this Picture. The upper left corner of the rectangle is at (x, y).

add_text(col, x, y, s)

Draw str s in Color col on this Picture starting at (x, y).

add_text_with_style(col, x, y, s, font)

Draw str s in Color col and font font on this Picture starting at (x, y).

close()

Close this Picture’s open PictureInspector window.

close_inspect()

Close this Picture’s open PictureInspector window.

copy()

Return a deep copy of this Picture.

crop(x1, y1, x2, y2)

Crop Picture pic so that only pixels inside the rectangular region with upper-left coordinates (x1, y1) and lower-right coordinates (x2, y2) remain. The new upper-left coordinate is (0, 0).

get_filename()

Return this Picture’s filename.

get_height()

Return how many pixels high this Picture is.

get_image()

Return this Picture’s PIL Image object.

get_pixel(x, y)

Return the Pixel at coordinates (x, y).

get_title()

Return this Picture’s title.

get_width()

Return how many pixels wide this Picture is.

has_coordinates(x, y)

Return True if (x, y) is a valid coordinate for this Picture.

inspect()

Inspect this Picture in a PictureInspector window, where inspection of specific pixels is possible.

is_closed()

Return True if this Picture is not being displayed.

save()

Write this Picture back to its file. If an extension is not specified the default is .bmp.

save_as(filename)

Write this Picture to filename filename and re-set filename and title. Make sure to specify the file format by the extension.

set_filename_and_title(filename)

If filename is a file set the filename and title of this Picture. Otherwise set both to the empty string.

set_image(image)

Set the PIL RGB Image image in this Picture and load the PixelAccess object from the Image.

set_title(title)

Set title of this Picture to str title.

show()

Inspect this Picture in a PictureInspector window, where inspection of specific pixels is NOT possible.

show_external()

Display this Picture in an external application. The application used is system dependant.

update()

Update this Picture’s open PictureInspector window

picture.create_image(w, h, col=Color(255, 255, 255))

Return a new PIL RGB Image object of Color col, w pixels wide, and h pixels high.

picture.get_short_path(filename)

Return the short path (containing directory and filename) of str filename.

picture.init_picture()

Initialize this Picture module. Must be done before using Pictures.

picture.load_image(f)

Return a new PIL RGB Image object loaded from filename f.

Previous topic

The media Module

Next topic

The pixel Module

This Page