For example, clicking the left and right mouse buttons will resize the image to the
display’s height and width dimensions, respectively, and pressing the I and O keys will
zoom the image in and out in 10 percent increments. Both resizing schemes allow you
to shrink an image too large to see all at once, as well as expand small photos. They
also preserve the original aspect ratio of the photo, by changing its height and width
proportionally, while blindly resizing to the display’s dimensions would not (height or
width may be stretched).
Once resized, images may be saved in files at their current size. PyPhoto is also smart
enough to make windows full size on Windows, if an image is larger than the display.
PyPhoto Source Code
Because PyPhoto simply extends and reuses techniques and code we met earlier in the
book, we’ll omit a detailed discussion of its code here. For background, see the dis-
cussion of image processing and PIL in Chapter 8 and the coverage of the canvas widget
in Chapter 9.
In short, PyPhoto uses canvases in two ways: for thumbnail collections and for opened
images. For thumbnails, the same sort of canvas layout code as the earlier thumbnails
viewer in Example 9-15 is employed. For images, a canvas is used as well, but the
Figure 11-8. PyPhoto open directory dialog (the D key)
PyPhoto: An Image Viewer and Resizer | 719