Images¶
Functions¶
Functions for displaying images inline in iTerm2.
See https://iterm2.com/images.html.
-
iterm2_tools.images.
display_image_bytes
(b, filename=None, inline=1, width='auto', height='auto', preserve_aspect_ratio=None)[source]¶ Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to “Unnamed file”.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session’s width or height.
- ‘auto’: The image’s inherent size will be used to determine an appropriate
- dimension.
preserve_aspect_ratio sets whether the aspect ratio of the image is preserved. The default (None) is True unless both width and height are set.
-
iterm2_tools.images.
display_image_file
(fn, width='auto', height='auto', preserve_aspect_ratio=None)[source]¶ Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session’s width or height.
- ‘auto’: The image’s inherent size will be used to determine an appropriate
- dimension.
preserve_aspect_ratio sets whether the aspect ratio of the image is preserved. The default (None) is True unless both width and height are set.
-
iterm2_tools.images.
image_bytes
(b, filename=None, inline=1, width='auto', height='auto', preserve_aspect_ratio=None)[source]¶ Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to “Unnamed file”
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session’s width or height.
- ‘auto’: The image’s inherent size will be used to determine an appropriate
- dimension.
preserve_aspect_ratio sets whether the aspect ratio of the image is preserved. The default (None) is True unless both width and height are set.