Ejemplo n.º 1
0
 def _dimensions(self, path):
     """
     Return object width and height
     Ususaly used for images, but can be realize for video etc...
     Can Raise a NotAnImageError
     """
     try:
         im = Image.open(path)
         return '%sx%s' % im.size
     except:
         raise NotAnImageError
Ejemplo n.º 2
0
 def _openimage(self, path):
     """
     Open an image file.
     """
     fp = self._fopen(path)
     #place the file contents in a temp file
     #this is necessary for remote storages, since PIL reads contents byte-by-byte
     tmp_file = tempfile.TemporaryFile()
     tmp_file.write(fp.read())
     fp.close()
     
     tmp_file.seek(0)
     im = Image.open(tmp_file)
     
     return im
Ejemplo n.º 3
0
 def _openimage(self, path):
     """
     Open an image file.
     """
     return Image.open(path)