Displays a picture.
<img [2481{...}]> displays the picture whose file data is given as 2481 bytes of raw data.<img width=240 height=160 [2481{...}]> displays it stretched or shrunk to 240 by 160 pixels.<pic [5320{...}]> replaces the picture shown by the img named pic.The picture file's data, sent as raw data. PNG, JPEG, GIF (including animated GIFs) and SVG are supported.
The picture is displayed at its own size unless width and height are given. Assigning new data to a named img replaces the picture.
The picture is drawn progressively as its data arrives. A picture that replaces a complete one appears once the new picture is complete; until then, the previous picture stays on screen.
To send a picture in pieces, clear the field, push each piece with .push, and then use .commit to show that the data is complete. The picture is drawn progressively as the pieces arrive, and is complete once it is committed.
The img tag does not generate a value.
Sending a picture file from Python:
import sys
def print_raw(filename):
with open(filename, 'rb') as f:
data = f.read()
print('[' + str(len(data)) + '{', end='', flush=True)
sys.stdout.buffer.write(data)
sys.stdout.buffer.flush()
print('}]', end='', flush=True)
print('<img ', end='')
print_raw('photo.png')
print('>')