buttons in row framesmuch like prior examples (see the input forms layout alternatives earlier in this most of the pil-specific code in this example is in the make thumbs function it openscreatesand saves the thumbnail imageunless one has already been saved ( cachedto local file as codedthumbnail images are saved in the same image format as the original full-size photo we also use the pil antialias filter--the best quality for down-sampling (shrinking)this does better job on low-resolution gifs thumbnail generation is essentially just an in-place resize that preserves the original aspect ratio because there is more to this story than we can cover herethoughi'll defer to pil and its documentation for more details on that package' api we'll revisit thumbnail creation again briefly in the next to create toolbar buttons before we move onthoughthree variations on the thumbnail viewer are worth quick consideration--the first underscores performance concepts and the others have to do with improving on the arguably odd layout of figure - performancesaving thumbnail files as isthe viewer saves the generated thumbnail image in fileso it can be loaded quickly the next time the script is run this isn' strictly required--example - for instancecustomizes the thumbnail generation function to generate the thumbnail images in memorybut never save them there is no noticeable speed difference for very small image collections if you run these alternatives on larger image collectionsthoughyou'll notice that the original version in example - gains big performance advantage by saving and loading the thumbnails to files on one test with many large image files on my machine (some images from digital camera memory stick and an admittedly underpowered laptop)the original version opens the gui in roughly just seconds after its initial run to cache thumbnailscompared to as much as minute and seconds for example - factor of slower for thumbnailsloading from files is much quicker than recalculation example - pp \gui\pil\viewer-thumbs-nosave py ""samebut make thumb images in memory without saving to or loading from filesseems just as fast for small directoriesbut saving to files makes startup much quicker for large image collectionssaving may be needed in some apps (web pages""import ossys from pil import image from tkinter import tk import viewer_thumbs def makethumbs(imgdirsize=( )subdir='thumbs') tkinter tourpart