压缩后的头像图像获得;轮换;用Python
我已经在我的应用程序中添加了头像的图像压缩代码。 但有时它会将上传的图像保存为“旋转” 请检查下面的代码压缩后的头像图像获得;轮换;用Python,python,django,compression,python-imaging-library,Python,Django,Compression,Python Imaging Library,我已经在我的应用程序中添加了头像的图像压缩代码。 但有时它会将上传的图像保存为“旋转” 请检查下面的代码 import Image, ImageFile pic = "pic/goes/here.jpg" im = Image.open(pic) width, height = im.size if width > 1000 or height > 1000: width = width*.7 height = height*.7 im = im.resiz
import Image, ImageFile
pic = "pic/goes/here.jpg"
im = Image.open(pic)
width, height = im.size
if width > 1000 or height > 1000:
width = width*.7
height = height*.7
im = im.resize((int(math.floor(width)), int(math.floor(height))), Image.ANTIALIAS)
try:
im.save(pic,optimize=True,quality=70)
except IOError:
ImageFile.MAXBLOCK = width * height
im.save(pic,optimize=True,quality=70)
我是否需要更新一些东西或其他替代方法来调整头像上传的图像大小?谢谢 请更改质量=70并重试 我发现85在我的6-10mb文件中没有区别,65是最低的合理数字