基本上我試圖通過用戶界面來旋轉圖像,但是我注意到每次旋轉後圖像質量嚴重下降。有誰知道如何解決這個問題?同樣,當圖像旋轉時,它會每次裁剪圖像的一部分。如何在使用PIL旋轉時保存圖像質量
這裏有一些圖片的前 後: http://imgur.com/a/QESKs
而這裏的代碼:
def onRotate(self):
tanTheta = float(hh)/float(ww)
theta = math.atan(tanTheta) * 57.2957795 # convert to degrees
if theta > 0:
angle = (90 - theta) * -1
clockwise = True
elif theta < 0:
angle = (270 - theta) * -1
clockwise = False
else:
tkMessageBox('Angle not okay', 'Try again!')
rotated_small = photo_small.rotate(angle)
rotated_small.save('small_rotate.jpg')
self.load_imgfile('small_rotate.jpg')
所以我認爲,而不是filter = Image.BICUBIC,它應該是resample = Image.BICUBIC。但這絕對有效!謝謝!! – loonyuni
@ user2525507我在http://effbot.org/imagingbook/image.htm上使用的文檔似乎有誤。我會解決答案。 –