Difference between revisions of "CSC111 Homework 5 2011"
(Created page with "--~~~~ ---- =Automatic Picture Editor= ==Overview== * Your assignment is to write a graphics program that takes a picture of you and modify it by apply several different transf...") |
(→Preparation) |
||
Line 16: | Line 16: | ||
* Then create a short '''python module''', called '''userInfo.py'''. Make sure you spell it exactly as shown, as your program wil be tested with a '''userInfo.py''' module of my own. | * Then create a short '''python module''', called '''userInfo.py'''. Make sure you spell it exactly as shown, as your program wil be tested with a '''userInfo.py''' module of my own. | ||
+ | <br /> | ||
+ | <source lang="python"> | ||
# userInfo.py | # userInfo.py | ||
# module containing information about a gif file | # module containing information about a gif file | ||
Line 23: | Line 25: | ||
height = 300 | height = 300 | ||
+ | </source> | ||
+ | <br /> | ||
:Of course, replace ''alexandra.gif'' by the actual name of your image file. | :Of course, replace ''alexandra.gif'' by the actual name of your image file. | ||
* You are now ready to write '''hw5.py''', a python program that will import everything from the userInfo.py module, and use it to conduct its transformation. | * You are now ready to write '''hw5.py''', a python program that will import everything from the userInfo.py module, and use it to conduct its transformation. |
Revision as of 08:05, 18 October 2011
--D. Thiebaut 09:05, 18 October 2011 (EDT)
Automatic Picture Editor
Overview
- Your assignment is to write a graphics program that takes a picture of you and modify it by apply several different transformations (similar to what we did to poor George Clooney).
- The challenging part is that your program should work for pictures of different geometry, and with different captions (more on that later).
Preparation
- Select a picture of yourself that is in the area of 300 by 200 pixels (if possible). Don't select something that is 1000 by 1000 or your program will take forever to process it and you will waste a lot of time debugging.
- The picture must have a gif extension, otherwise the graphics.py library will not be able to load it. Very likely the picture you will have of yourself will have a jpg, jpeg, or png extension. That's ok, you can transform it to a gif extension by uploading it to this Web site and downloading the gif version: www.coolutils.com
- Once you have the picture, put it in the same directory (folder) where your python program will reside.
- Find out the width and height of your image (use Google to help you figure out how to do this with Windows or Mac OSX).
- Then create a short python module, called userInfo.py. Make sure you spell it exactly as shown, as your program wil be tested with a userInfo.py module of my own.
# userInfo.py
# module containing information about a gif file
# to be process by hw5.py
filename = "alexandra.gif"
width = 400
height = 300
- Of course, replace alexandra.gif by the actual name of your image file.
- You are now ready to write hw5.py, a python program that will import everything from the userInfo.py module, and use it to conduct its transformation.
- Here's a debugging version of hw5.py that will help you figure out how things will work.
# hw5.py
# your name
from userInfo import *
from graphics import *
def main():
print( "Gif file: ", filename ) # this will print alexandra.gif
print( "width of gif file: ", width ) # this will print 400
print( "height of gif file: ", height ) # this will print 300
main()
</source>