Django

Code

root/django/branches/gis/django/utils/images.py

Revision 4265, 458 bytes (checked in by adrian, 2 years ago)

Fixed #3191 -- Set 'svn:eol-style native' on the files that didn't have it. Thanks, jjl@pobox.com

  • Property svn:eol-style set to native
  • Property svn:keywords set to LastChangedRevision
Line 
1 """
2 Utility functions for handling images.
3
4 Requires PIL, as you might imagine.
5 """
6
7 import ImageFile
8
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
Note: See TracBrowser for help on using the browser.