Simple démonstration sur comment créer une image avec python à partir d'une partie d'une autre image en utilisant le module PIL.
import Image
# Download Image:
im = Image.open("lena.png")
# Check Image Size
im_size = im.size
print im_size
# Define box inside image
left = 182
top = 200
width = 200
height = 200
# Create Box
box = (left, top, left+width, top+height)
# Crop Image
area = im.crop(box)
area.show()
# Save Image
print area.size
area.save("lena_selected_part.png", "PNG")
Recherches associées
Liens | Site |
---|---|
Python Imaging Library (PIL) | PIL doc |
Crop the image using PIL in python | stackoverflow |
The Image Module | effbot |
Trouble using python PIL library to crop and save image | stackoverflow |