Class 21 — March 12
Trying out a new pillow
Pillow is software — Go try and figure it out — For a thousand words
Look both ways
Agenda
- Introduce Pillow for image generation and manipulation
Downloads
- Module util.py
- Provides the ability to get photos into a Python program
- Module test-pillow.py
- Tests that the pillow module was successfully installed
- Program wahoo.py
- Lets you overlay a selfie with UVA orange and blue dots (for fun)
- Program gradient.py
- Paints a gradient (for fun)
- Program groovy.py
- Paints a psychedelic image (for fun)
- Program canvases.py
- Paints a series of colored images
- Program pillow_painting.py
- Demonstrates basic Pillow drawing commands
Discussion
- Pillow is a library for manipulating images in Python. Unlike the math library and others we have used, Pillow is not part of the standard Python install; you have to add it yourself.
- To install Pillow on your laptop go here.
- For now the parts of Pillow of interest to us are:
- Image: Pillow representation of an image.
- ImageDraw: Pillow image drawing commands.
- The Image has one particular function of current interest to us:
Image.new( m, size, color='black' )
returns a mode m new image, whose dimensions are size. The background of the image color. Parameter color is optional with a default value of black. For us,
m
will always be the string'RGB'
;
size
will always be an ordered pair of the form( w, h )
, wherew
is the width of the image andh
is the height of the image.
- The ImageDraw has a host of drawing commands. Many of them are demonstrated in pillow_painting.py
To do
- Look over artifacts
- Review pillow_painting.py
- Review Pillow drawing module
- Review Pillow drawing epistle
- Checkout last semester artistry
- Checkout past artistry highlights
Imagery
Warning: fopen(/l/cs1112/public_html/defs/htm/181-trailer): Failed to open stream: No such file or directory in /l/cs1112/public_html/defs/php/read.php on line 5
Unable to open file!