Non-filter Components: 8 points
We’ll start by implementing the menu for your program. Your program should begin by printing a welcome to the user. You should then prompt the user in the console to enter the name of a file to load. You should use a try-except block to make sure that the file exists. If a FileNotFoundError
occurs, instead of letting the raw error message show up, your program should print a message to the user letting them know that the file with the provided name does not exist and ask them to try again.
Once you have an image loaded, display it. Next, use a while
loop to repeatedly do the following:
For example, the user might choose to reflect the image, then increase the contrast (of the now reflected image), and then blur (the now reflected and contrasted image). At each step, the user should be able to see the resulting image. For now, since you haven’t actually implemented the functions for the operations yet, you should implement placeholder conditional statements for all of the above and then test the filters as you implement them throughout the lab.
picture.save_picture()
vs picture.display()
The picture
module provides several methods for viewing graphics output. Until now, you’ve only been using picture.save_picture()
. This function saves the picture as a standalone file in the repository. What if you want to update an image while your program is running indefinitely? In that case, you’ll need to use picture.display()
. This function creates or updates an image window with the current image, then will close itself as soon as the program ends. Since your imagegram.py
program will use a while
loop to monitor the user’s input and keep the application running until it is stopped by the user or an error that crashes the program, you should use picture.display()
immediately after applying a new filter.
You can find more information about picture.save_picture()
and picture.display()
in the picture
module documentation.
The menu should keep prompting the user to select a filter until they select the Quit option. At the end of this part of the lab, interacting with your program should look something like this:
Welcome to Imagegram!
Please enter a filename: crayons.jpg
Which of the following filters would you like to apply?
1. Make Negative
2. Make Grayscale
3. Flip Vertically
4. Scroll Horizontally
5. Zoom
6. Blur
0. Quit
Choice: 1
Which of the following filters would you like to apply?
1. Make Negative
2. Make Grayscale
3. Flip Vertically
4. Scroll Horizontally
5. Zoom
6. Blur
0. Quit
Choice: 0
Goodbye!
Reminder
As you make progress on your menu, don’t forget to commit and push your changes regularly.