如何使用PIL获取图像大小(字节) [英] How to get image size (bytes) using PIL
本文介绍了如何使用PIL获取图像大小(字节)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了如何使用PIL来获取图像尺寸,而不是文件大小(以字节为单位).我需要知道文件大小,以确定文件是否太大而无法上传到数据库.
I found out how to use PIL to get the image dimensions, but not the file size in bytes. I need to know the file size to decide if the file is too big to be uploaded to the database.
推荐答案
尝试:
import os
print os.stat('somefile.ext').st_size
这篇关于如何使用PIL获取图像大小(字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文