Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from base64 import encode_bytes 

2from os import STDOUT 

3from os import Stdout 

4 

5func write_png(image: bytes): 

6 """Write given image to the terminal. 

7 

8 """ 

9 

10 encoded = encode_bytes(image) 

11 STDOUT.write(b"\x1b_Ga=T,f=100,m=1\x1b\\") 

12 

13 for offset in range(0, encoded.length(), 4096): 

14 STDOUT.write(b"\x1b_Gm=1;") 

15 STDOUT.write(encoded, offset, 4096) 

16 STDOUT.write(b"\x1b\\") 

17 

18 STDOUT.write(b"\x1b_Gm=0\x1b\\\n")