Python如何获取JPG图片的长宽等信息

PIL模块地址:

http://www.pythonware.com/products/pil/

下载安装PIL:Ubuntu 上 python PIL库的安装

如果是在LINUX下,编译过程中遇到到错误找不到“Python.h”头文件,请先sudo apt-get install python-dev。

PIL的示例代码:

# coding: utf8
# 获取指定图片的长和宽
from PIL import Image
img = Image.open("img.jpg")
print img.size
 
运行结果:
(52, 54)


你可能感兴趣的:(python,图片,jpg)