Lab: Collage

Feeling pretty

Part I: Setup

In class we discussed modules and objects and did some examples using my simple glib module. For this lab, you are going to download glib.py and make a cool-looking collage of images.

For this lab, you'll end up with the following files in the same directory:

  • glib.py, my library that you download
  • main.py, your code file that imports glib
  • Whatever image files you choose to use

Bring your complete project to lab on Friday to show off. To submit it, you'll put the files in a compressed (zip) archive and attach it to the blackboard submission.

Before you can use glib, you'll need to install the PIL image processing library in your copy of Python. Run the following command at a sytem command prompt (not in Python!). On windows, you click the start menu and type cmd to bring up a black-box command prompt. On Mac or Linux, use a terminal.

py -3 -m pip install Pillow

Test your install by opening up Python and typing import PIL at the interactive top level. If it doesn't error, you're all good.

Part II: glib docs

The glib module has documentation strings included with its functions. I used pydoc to automatically generate the documentation here. Use this as a reference to know what you can do with glib.

Remeber! The first thing you need to do in your code file is import glib, either the whole thing, or the functions you want to use.

You can also check the example from class today if you need a kickstart, but I encourage you to try starting from scratch on your own first.

Part III: Art!

Make a collage of images! Guidelines and example below.

  • When you run your program, it should open a 1024x768 GUI window (like we did in class) and show your collage of images.
  • The same picture must appear at least four times: Once in its original form, then three more times modified in some way.
  • You must use resize at least twice.
  • You must use at least four other manipulation functions besides resize.

An example collage:

Some extra credit

We talked at the end of class about how glib is just a convenience wrapper around other modules, so that you can do everything with functions. I deliberately did not wrap the ImageFilter functionality that also comes with PIL.

For extra credit, utilize three of the predefined image enhancement filters in the ImageFilter module (EMBOSS, FIND_EDGES, etc). The docs are here so you can figure out how to access and use it.