![图片[1]-如何在python里获取导入图片的大小?-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5ec72bf41d0a8443.jpg)
在python中获取导入图片大小的方法:
1、获取图片尺寸大小
importos fromPILimportImage path=os.path.join(os.getcwd(),"23.png") img=Image.open(path) printimg.format#PNG printimg.size#(3500,3500)
2、获取图片物理大小
#!-*-coding:utf-8-*-
importrequests
importio
url="http://s1.sinaimg.cn/large/001Db1PVzy7qxVQWMjs06"
image=requests.get(url).content
image_b=io.BytesIO(image).read()
size=len(image_b)
print("{}byte\n{}kb\n{}Mb".format(size,size/1e3,size/1e6))原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END


















































暂无评论内容