web/lib/django/core/files/images.py
changeset 29 cc9b7e14412b
parent 0 0d40e90630ef
equal deleted inserted replaced
28:b758351d191f 29:cc9b7e14412b
    28                 self.close()
    28                 self.close()
    29         return self._dimensions_cache
    29         return self._dimensions_cache
    30 
    30 
    31 def get_image_dimensions(file_or_path):
    31 def get_image_dimensions(file_or_path):
    32     """Returns the (width, height) of an image, given an open file or a path."""
    32     """Returns the (width, height) of an image, given an open file or a path."""
    33     from PIL import ImageFile as PILImageFile
    33     # Try to import PIL in either of the two ways it can end up installed.
       
    34     try:
       
    35         from PIL import ImageFile as PILImageFile
       
    36     except ImportError:
       
    37         import ImageFile as PILImageFile
       
    38         
    34     p = PILImageFile.Parser()
    39     p = PILImageFile.Parser()
    35     close = False
    40     close = False
    36     if hasattr(file_or_path, 'read'):
    41     if hasattr(file_or_path, 'read'):
    37         file = file_or_path
    42         file = file_or_path
    38     else:
    43     else: