def from_buffer(cls, buffer_): """Instantiate an image container from an image memoryview. Args: buffer_ -- a memoryview containing image data as bytes """ obj = cls(None) obj.__image = libexiv2python._Image(buffer_, len(buffer_)) return obj
def from_buffer(cls, buffer): """ Instantiate an image container from an image buffer. :param buffer: a buffer containing image data :type buffer: string """ obj = cls(None) obj.__image = libexiv2python._Image(buffer, len(buffer)) return obj
def _instantiate_image(self, filename): # This method is meant to be overridden in unit tests to easily replace # the internal image reference by a mock. if not os.path.exists(filename) or not os.path.isfile(filename): raise IOError(ENOENT, os.strerror(ENOENT), filename) # Remember the reference timestamps before doing any access to the file stat = os.stat(filename) self._atime = stat.st_atime self._mtime = stat.st_mtime return libexiv2python._Image(filename)