Updated ez_setup.py from 0.6a7 to 0.6a9
[fdr-django.git] / django / utils / images.py
blob122c6ae233aba90d7cd454053aa3fc353a31cdfb
1 """
2 Utility functions for handling images.
4 Requires PIL, as you might imagine.
5 """
7 import ImageFile
9 def get_image_dimensions(path):
10 """Returns the (width, height) of an image at a given path."""
11 p = ImageFile.Parser()
12 fp = open(path, 'rb')
13 while 1:
14 data = fp.read(1024)
15 if not data:
16 break
17 p.feed(data)
18 if p.image:
19 return p.image.size
20 break
21 fp.close()
22 return None