opening and saving image in python makes an empty file

时间:2018-03-09 19:02:48

标签: python

I am just starting to learn python. I am trying to make a program that opens a file, crops it and saves it. I wrote this:

from PIL import Image

image = Image.open('boi.jpg')
crop = image.crop((0,0,200,200))
crop.save("boicropped.jpg","JPEG")

This makes an empty file that i can not open: boicropped

i am sorry if it is an obvious mistake i am missing...

1 个答案:

答案 0 :(得分:0)

Too low of rep to comment new to SO, I would remove your declaration of crop. Encapsulate your cropping of image, and follow with .save.