Trouble using python PIL library to crop and save image

前端 未结 2 596
攒了一身酷
攒了一身酷 2020-12-23 16:49

Im attempting to crop a pretty high res image and save the result to make sure its completed. However I keep getting the following error regardless of how I use the save me

2条回答
  •  爱一瞬间的悲伤
    2020-12-23 17:03

    The box is (left, upper, right, lower) so maybe you meant (2407, 804, 2407+71, 804+796)?

    Edit: All four coordinates are measured from the top/left corner, and describe the distance from that corner to the left edge, top edge, right edge and bottom edge.

    Your code should look like this, to get a 300x200 area from position 2407,804:

    left = 2407
    top = 804
    width = 300
    height = 200
    box = (left, top, left+width, top+height)
    area = img.crop(box)
    

提交回复
热议问题