Cropping Image - Image.crop Function Not Working
I have following line of code for image cropping im = Image.open('path/to/image.jpg') outfile = 'path/to/dest_img.jpg' im.copy() im.crop((0, 0, 500, 500)) im.thumbnail(size, Imag
Solution 1:
You have forgotten to assign the return values in some statements.
im = Image.open('path/to/image.jpg')
outfile = "path/to/dest_img.jpg"
im = im.crop((0, 0, 500, 500))
im = im.thumbnail(size, Image.ANTIALIAS)
im.save(outfile, "JPEG")
Solution 2:
You certainly want to do this:
from PIL import Image
im = Image.open('sth.jpg')
outfile = "sth2.jpg"
region=im.crop((0, 0, 500, 500))
#Do some operations here if you want but on region not on im!
region.save(outfile, "JPEG")
Post a Comment for "Cropping Image - Image.crop Function Not Working"