0
image.thumbnail((128,128),Image.ANTIALIAS)PIL調整大小圖像
PIL設置新圖像的高度給定(128這裏)的尺寸和計算出的寬度,以保持高寬比。
有沒有辦法將寬度設置爲128,並讓它計算高度以保持縱橫比?
image.thumbnail((128,128),Image.ANTIALIAS)PIL調整大小圖像
PIL設置新圖像的高度給定(128這裏)的尺寸和計算出的寬度,以保持高寬比。
有沒有辦法將寬度設置爲128,並讓它計算高度以保持縱橫比?
根據文檔縮略圖方法:
Modifies the image to contain a thumbnail version of itself, no larger than the given size.
嘗試設置寬度爲128,使用高度大的數目(例如10000)。
好,如果一切都失敗了,你永遠可以使用Python直接作爲計算器:
width_ratio = image.size[0]/128.0
new_height = image.size[1]/width_ratio