app/django/utils/images.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sun, 12 Oct 2008 01:08:41 +0000
changeset 300 d36b597ef29d
parent 54 03e267d67478
permissions -rw-r--r--
Changed location of the svn command in svn_load_dirs.pl script from '/usr/bin/svn' to 'svn'. That makes the script more universal and it should work on Linux, Windows and Mac OS X if the svn is in the PATH. Patch by: Pawel Solyga Review by: to-be-reviewed

"""
Utility functions for handling images.

Requires PIL, as you might imagine.
"""

import ImageFile

def get_image_dimensions(path):
    """Returns the (width, height) of an image at a given path."""
    p = ImageFile.Parser()
    fp = open(path, 'rb')
    while 1:
        data = fp.read(1024)
        if not data:
            break
        p.feed(data)
        if p.image:
            return p.image.size
            break
    fp.close()
    return None