#pip install pillow

import os
from PIL import Image
#本地图片
path = os.path.join(os.getcwd(),"23.png")
img = Image.open(path)
print img.format        # PNG
print img.size          # (3500, 3500)

#远程图片
path = "http://h.hiphotos.baidu.com/image/pic/item/c8ea15ce36d3d5397966ba5b3187e950342ab0cb.jpg"
file = urllib2.urlopen(path)
tmpIm = cStringIO.StringIO(file.read())
img = Image.open(tmpIm)

print img.format         # JPEG
print img.size           # (801, 1200)