Cropping an image with Python Pillow Cropping an image with Python Pillow python-3.x python-3.x

Cropping an image with Python Pillow


The problem is with logic, not Pillow. Pillow is nearly 100% PIL compatible. You created an image of 0 * 0 (left = right & top = bottom) size. No display can show that. My code is as follows

from PIL import Imagetest_image = "Fedora_19_with_GNOME.jpg"original = Image.open(test_image)original.show()width, height = original.size   # Get dimensionsleft = width/4top = height/4right = 3 * width/4bottom = 3 * height/4cropped_example = original.crop((left, top, right, bottom))cropped_example.show()

Most probably this is not what you want. But this should guide you towards a clear idea of what should be done.