如何基于Python获取图片的物理尺寸
时间:2021-02-06 10:03:32|栏目:Python代码|点击: 次
这篇文章主要介绍了如何基于Python获取图片的物理尺寸,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
问题
如何获取图片的物理尺寸,而非(width, height)?
代码
以女神图为例

#! -*- coding: utf-8 -*-
import requests
import io
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))
结果
75264 byte 75.264 kb 0.075264 Mb
注意
上一篇:python 实现数组list 添加、修改、删除的方法
栏 目:Python代码
本文标题:如何基于Python获取图片的物理尺寸
本文地址:http://www.codeinn.net/misctech/57812.html






