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
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
def _openimage(self, path): """ Open an image file. """ return Image.open(path)