188. Image Processing with PIL/Pillow
1. Opening and Displaying an Image
Copy
from PIL import Image
# Open an image
img = Image.open("example.jpg")
# Display the image
img.show()2. Resizing an Image
Copy
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")3. Cropping an Image
Copy
4. Rotating an Image
Copy
5. Applying a Filter to an Image
Copy
6. Converting an Image to Grayscale
Copy
7. Adding Text to an Image
Copy
8. Creating a Thumbnail
Copy
9. Merging Two Images
Copy
10. Extracting Image Metadata
Copy
Last updated