Closed olegchomp closed 1 year ago
I'm using python code like this:
async for msg in websocket:
if isinstance(msg, bytes):
s = struct.calcsize(">II")
data = memoryview(msg)
if len(data) > s:
event, format = struct.unpack_from(">II", data)
if event == 1 and format == 2: # 1=PREVIEW_IMAGE, 2=PNG, see ComfyUI server.py
return Image.png_from_bytes(data[s:])
where Image.png_from_bytes
does QImage.fromData(data, "PNG")
because I use Qt anyway, but you can use similar method with eg. PIL.Image.open
Thank you!
Hi! Can you provide code example for decoding image?