How to obtain image size using standard Python class (without using external library)?
问题 I am using Python 2.5. And using the standard classes from Python, I want to determine the image size of a file. I\'ve heard PIL (Python Image Library), but it requires installation to work. How might I obtain an image\'s size without using any external library, just using Python 2.5\'s own modules? Note I want to support common image formats, particularly JPG and PNG. 回答1: Here's a python 3 script that returns a tuple containing an image height and width for .png, .gif and .jpeg without