from PIL import Image
im = Image.open("1.jpg")
img_size = im.size
print("w,h{}".format(img_size))
x = (600 - 448)/2
y = (967 - 448)/2
w = 448
h = 448
im = im.crop((x, y, x+w, y+h))
x = (448 - 224)/2
y = (448 - 224)/2
w = 224
h = 224
im = im.crop((x, y, x+w, y+h))
im.save("1_m.jpg")
ima = Image.open("1.jpg")
x = 188
y = int((967 - 448)/2 + 112)
print("y",y)
w = 224
h = 224
ima = ima.crop((x, y, x+w, y+h))
ima.save("2_m.jpg")
xmin = 268 - x
ymin = 439 - y
xmax = 416 - x
ymax = 486 - y
print("xmin,ymin,xmax,ymax = ",xmin,ymin,xmax,ymax)
|