
In this project, you will arrange images and text to create memes. You will use lists to organize which images and text goes where in your grid.
Make a copy of show.py and rename it meme.py
In your main function of meme.py create two text objects, one centered at the bottom of the image and one centered at the top of the image. Choose a font size and color that is visible
Draw the text objects after the image is drawn.
Run your code to make sure it produces the correct result.
Allow the user to pass in two optional command-line arguments to meme.py. The first string will be the text for below the image, and the second string will be the text for above the image. Be sure to pass the command line arguments as function parameters to your main function and change your Text object constructors to use those parameters. Give empty strings as the optional function argument for your two new parameters.
Here is an example of showing the image miller.ppm with the top text top text "Hi" and the bottom text "Welcome to Colby".
python3 meme.py miller.ppm "Welcome to Colby!" "Hi!"
Imagine giving meme.py or show.py to a friend and they tried to run your code. The program would crash with a unhelpful error message because they don't know that they need to pass in the image filename as a command-line argument (try it!). Frustrating!
From now on, you will be expected to print a proper usage statement if your program uses command-line arguments (so that the user knows how to run your program!).
In both meme.py and show.py, check the number of command-line arguments that the user passes in. If the user does not pass in enough command-line arguments, print out how to run your code without crashing. Here is a good example:
Usage: python3 show.py <filename of image>
Call the exit function right after printing out the message to stop the program cleanly without crashing.
Test running meme.py and show.py with the correct and incorrect number of command-line arguments. For example, running show.py:
In your project folder, create a new folder called images. Put two png or ppm images in the images folder that you would like to use for your memes.
Take a screenshot of the meme that you created with 2 command line arguments this is Required Image 1 in your project. In your report include the command line arguments you used to produce the meme.
Take a screenshot of the meme that you created with 3 command line arguments this is Required Image 2 in your project. In your report include the command line arguments you used to produce the meme.

For this project you'll be creating a vertical multi-panel meme, in the same format as the meme above.
Make a new file called multimeme.py. In it, create a main function in which you will write code to create your multi-panel meme.
Write a meme function that generate the image objects and text objects for a meme. Center the meme on the x axis around 0 and have the top of the meme start at topleft_y. Returns a list containing the image and text objects, the height of the image and the width of the image.
def meme(panel_list, topleft_y ): '''Generate the image objects and text objects for a meme that is centered on the x axis and the top of the meme starts at topleft_y. Returns a list containing the image and text objects, the height of the image and the width of the image. Parameters: ----------- panel_list: A list with 1-3 strings, panel_list[0] is the image filename, (optional) panel_list[1] is the bottom text for the meme, (optional) panel_list[2] is the top text for the meme. topleft_y: int. y position where the top-left corner of `img` should go. Return: ----------- shapes: A list of image and text objects to create the meme. img_width: int. the width of the image object. img_height: int. the height of the image object. ''' pass
Write a test function that creates a window and uses the meme function to generate the image and text objects for a meme. Use a for loop to center the objects on the y axis and draw them.
Call your test function and make sure it works properly.
Use a list of lists to store information about each meme in the canvas. Each sublist relates to one of the memes and has up to 3 items:
Here is an example with for two memes:
imageList = [ ['programmer.png', 'I have no idea why', 'My code doesn't work'] , ['programmer.png', 'I have no idea why', 'My code works'] ]
Design a meme that has at least 3 panels. Create a list with sublists to represent the multi-panel meme.
Requirement: You should use a list of lists to organize each image and its text for your final multi-panel meme.
Create a main function.
Test your code with different imageLists, that have 1, 2 and 3 sublists. Your code should work with any number of panels.
Take a screen shot of your multi-panel meme; this is Required Image 3 in your project.
In order to grade your project, we need to be able to run your code and get the same results as you do!
In your project submission ZIP file, please include any PPM images that are needed run your code.
Here is a summary of the expected outputs from each of the source code files that you created:
python3 show.py <image filename>: In a new window display the image passed in by command-line arguments. (see note about command-line arguments below).python3 meme.py <image filename> <bottom text> <top text>: In a new window display the image passed in by command-line arguments, with the top text at the top of the image, and the bottom text at the bottom of the image.python3 multimeme.py: In a new window display a meme with atleast 3 panels controlled by a list with sublists.If you use command-line arguments in any file, please explain what they are and provide an example way to run your code in either code comments or your report. It is ok to deviate from the suggested command-line arguments, but you need to document how the user should run your code!
Congratulations on completing the core tasks! If your code and report meet the above expectations, you’ve already earned up to 26/30 points for this project.
The remaining 4/30 are a chance for you to earn credit for exploring parts of this project and digging deeper to express your creativity! This is entirely optional; 26/30 is a B and is a perfectly respectable place to stop. Extensions are open-ended and exist to compliment the structured core project. Explore and learn something new that interests you! Concentrating your energy on 1-2 "deep" extensions that challenge you will earn you more points than many small, "shallow" extensions.
You can pick your own topics that interest you. Here are a few examples:
To turn in your project, make sure you do all of the following:
/Courses/CS151_A_FA/<your username>/Private/Projects/<your username>_P05./Courses/CS151_A_FA/<your username>/Private/Projects/<your username>_P05/Lab_05./Courses/CS151_A_FA/<your username>/Private/Projects/<your username>_P05.<your username>_P05.© 2023 Hannen Wolfe