我希望找到一种压缩图像并保持相同方向的方法。
我的代码:
def save(self, **kwargs):
super(Post, self).save()
if self.picture:
mywidth = 1100
image = Image.open(self.picture)
wpercent = (mywidth / float(image.size[0]))
hsize = int((float(image.size[1]) * float(wpercent)))
image = image.resize((mywidth, hsize), Image.ANTIALIAS)
image.save(self.picture.path)
即使我只使用这个片段:
image = Image.open(self.picture)
然后无需进行任何操作即可保存
image.save(self.picture.path)
它仍然给我带来了方向改变的图片...