Skip to content
Snippets Groups Projects
Select Git revision
  • aa8ab8ffd6f3ff405093b13f148099566496c625
  • main default protected
2 results

README.md

Blame
  • show_image.py 688 B
    import numpy as np
    import base64
    from PIL import Image
    import zlib as zl
    
    
    def show_image(format, width, height, image):
        image_decoded = base64.b64decode(image)
        print(len(image_decoded))
        print(type(image_decoded))
        #image_data = ... # byte values of the image
        image = Image.frombytes(format, (width,height),image_decoded,'raw')
        image.show()
    
        # Save to file
        a=np.asarray(image)
        im = Image.fromarray(a)
        im.save("your_file.jpeg")
    
    def inflate(data):
        decompress = zl.decompressobj(
                -zl.MAX_WBITS  # see above
        )
        inflated = decompress.decompress(data)
        inflated += decompress.flush()
        return inflated