Let's make a simple code to resize an image that you have in the same dir where we have the .py script.
from PIL import Image img = Image.open('code.jpg') wh = 200,300 img = img.resize(wh,Image.ANTIALIAS) img.save("code2.png") print("Image resized, look in the dir")
1.You will need the PIL module.
2. you will open the image and give it the name img
3. set the width (w) and the height(h) as a tuple
4. resize the image with the wh (tuple above) and with Image.ANTIALIAS to make the final product better,
5. Save the file with a new name
6. print a message on the console to ensure the script is done.
See ya
Comments
Post a Comment