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 Sizeim_size = im.sizeprint im_size# Define box inside imageleft = 182top = 200width = 200height = 200# Create Boxbox = (left, top, left+width, top+height)# Crop Imagearea = im.crop(box)area.show()# Save Imageprint area.sizearea.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 |
