如何在python中压缩图像文件?
我正在进行一个文件传输项目,我希望从服务器下载的图像以压缩格式下载。我如何使用python来实现它?如何在python中压缩图像文件?,python,optimization,compression,python-imaging-library,Python,Optimization,Compression,Python Imaging Library,我正在进行一个文件传输项目,我希望从服务器下载的图像以压缩格式下载。我如何使用python来实现它? 我想使用PIL模块来减小用户下载的每个图像的大小。此函数将获取ur文件的输入路径,并将所有图像的输出作为zip文件发送到taht路径 def zipper(path): """ This function archives the output folder for more than one image files """ #
我想使用PIL模块来减小用户下载的每个图像的大小。此函数将获取ur文件的输入路径,并将所有图像的输出作为zip文件发送到taht路径
def zipper(path):
"""
This function archives the output folder for more than one image files
"""
# check if more than one files are there in output path
total_image_files = os.listdir(path)
zip_file = path +"/img.zip"
zf = zipfile.ZipFile(zip_file, mode='w')
for fe in total_image_files:
zf.write(path + "/" + fe, arcname = fe)
zf.close()
return zip_file
你的问题目前很模糊。请添加一些详细信息。为什么你不能只提供有自己压缩的图像,比如PNG格式?