188. Image Processing with PIL/Pillow
from PIL import Image
# Open an image
img = Image.open("example.jpg")
# Display the image
img.show()from PIL import Image
# Open an image
img = Image.open("example.jpg")
# Resize the image to 200x200 pixels
resized_img = img.resize((200, 200))
# Save the resized image
resized_img.save("resized_example.jpg")from PIL import Image
# Open an image
img = Image.open("example.jpg")
# Crop the image (left, upper, right, lower)
cropped_img = img.crop((50, 50, 200, 200))
# Save the cropped image
cropped_img.save("cropped_example.jpg")Last updated