Answered step by step
Verified Expert Solution
Link Copied!

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 2: Image correction
To start this part, you are going to create a new file called check2_helper.py and create a function
in it called make_square. 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
x-axis. If the image is longer than wider (vertical), then you must crop it along the y-axis. 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:
im= Image.open ('1.jpg')
imsquare =makesquare(im)
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 1 to a new file called
check2.py. Modify your code so that:
You now import your own module check2_helper.py
You use your own function from this module to make each image in the wallpaper square
before resizing them.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions