Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
压缩后的头像图像获得;轮换;用Python_Python_Django_Compression_Python Imaging Library - Fatal编程技术网

压缩后的头像图像获得;轮换;用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是最低的合理数字