Skip to content Skip to sidebar Skip to footer

Byte Stream And Utf-8 In Python 3

I am reading a blob from a database which contains a png file. The blob looks correct and is of a bytes data type. It starts: b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x92\

Solution 1:

wx.Image() does not support creating an image from a raw byte stream. The class has instead interpreted it as a filename (which must be a string, so it is being decoded).

Wrap your data in a io.BytesIO() object; wx accepts such objects as streams:

importioimage= wx.Image(io.BytesIO(blob))

Post a Comment for "Byte Stream And Utf-8 In Python 3"