def get_image ( self , source ) : buf = StringIO ( source . read ( ) ) return Image . open ( buf )
how to open image from content in python
Given a file - like object loads it up into a PIL . Image object and returns it .
def get_image(self, source):
        """
        Given a file-like object, loads it up into a PIL.Image object
        and returns it.

        :param file source: A file-like object to load the image from.
        :rtype: PIL.Image
        :returns: The loaded image.
        """
        buf = StringIO(source.read())
        return Image.open(buf)