def process_image(self, item):
    image = Image.open(item.photo)
    left = int(self.cleaned_data['crop_x'])
    top = int(self.cleaned_data['crop_y'])
    width = int(self.cleaned_data['crop_width'])
    height = int(self.cleaned_data['crop_height'])
    box = (left, top, (left + width), (top + height))
    image = image.crop(box)
    f = BytesIO()
    try:
        image.save(f, format='jpeg')
        s = f.getvalue()
        item.photo.save(item.photo.name, ContentFile(s))
    finally:
        f.close()
def process_image(self, item):
    image = Image.open(item.photo)
    left = int(self.cleaned_data['crop_x'])
    top = int(self.cleaned_data['crop_y'])
    width = int(self.cleaned_data['crop_width'])
    height = int(self.cleaned_data['crop_height'])
    box = (left, top, (left + width), (top + height))
    image = image.crop(box)
    f = BytesIO()
    try:
        image.save(f, format='jpeg')
        s = f.getvalue()
        item.photo.save(item.photo.name, ContentFile(s))
    finally:
        f.close()