Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Checkpoint 2 : Image correction To start this part, you are going to create a new file called check 2 _ helper.py and create a
Checkpoint : Image correction
To start this part, you are going to create a new file called checkhelper.py and create a function
in it called makesquare. Your function takes as an argument an image object, crops it to make it
square and returns the resulting image. Remember to import Image in your file.
In your function, you will check the size of the image and crop some part of it to make it into
a square image. If the image is wider than longer horizontal then you must crop it along the
axis. If the image is longer than wider vertical then you must crop it along the yaxis. Always
start from the top left corner.
Check the course notes for finding the size of an image and cropping. Remember that the crop
function returns a new image.
Now write some simple code to use this function to make one of the images from first checkpoint
square and show. We recommend you try this with some of the images titled inc as well to see if
it works for horizontal images as well as vertical ones.
Here is how example test code should look:
Image.open
imsquare quare
imsquare.show
You see that your function does not open an image, but takes an image as input argument, and
returns a new image. Once you are convinced that your function works, leave nothing in the file
but the function.
Copy your solution from checkpoint to a new file called
checkpy Modify your code so that:
You now import your own module checkhelper.py
You use your own function from this module to make each image in the wallpaper square
before resizing them.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started