1
import PIL
from PIL import Image
img = Image.open('0009_jpg.jpg')
width, height = img.size #height is 720 and width is 480
if height > width:
rm_height = abs(height - width) # rm_height = 240
x_offset = 0
y_offset = rm_height/2 # y_offset = 120
tall = height-rm_height # tall = 480
img_crop = img.crop((x_offset, y_offset, width, tall))
img_crop.save('crop_jpg.jpg')
輸出圖像是小480x360 resulution不小480x480PIL裁剪圖像給予高度不正確的結果
但是當我此行更改爲
tall = height-rm_height/2 # tall = 600
輸出圖像是方形小480x480
它不會使感。我做錯了什麼。謝謝
這是什麼說的? – physicalattraction
來自克里斯克拉克,這是說im.crop((左,上,右,下)) – gongsun