How to preserve Image Quality when rotating with PIL

前端 未结 2 1211
自闭症患者
自闭症患者 2021-01-05 03:28

Basically I\'m trying to be able to rotate images via user interface, however I\'ve noticed that the image quality severely decreases upon each rotation. Does anyone know ho

2条回答
  •  时光说笑
    2021-01-05 04:05

    rotated_small = photo_small.rotate(angle, resample=Image.BICUBIC, expand=True)
    

    This tells it to use the highest quality interpolation algorithm that it has available, and to expand the image to encompass the full rotated size instead of cropping. The documentation does not say what color the background will be filled with.

提交回复
热议问题