Reference
Top-Level Functions
- term_img.get_font_ratio()
Return the set libray-wide font ratio
- Return type
float
- term_img.set_font_ratio(ratio)
Set the library-wide font ratio
- Parameters
ratio (float) – The aspect ratio of your terminal’s font i.e width / height of a single character cell.
- Return type
None
This value is taken into consideration when rendering images in order for images drawn to the terminal to have a proper perceived scale.
If you can’t determine this value from your terminal’s configuration, you might have to try different values till you get a good fit. Normally, this value should be between 0 and 1, but not too close to either.
Image Format Specification
[h_align] [width] [ . [v_align] [height] ] [ # [threshold | bgcolor] ]
Note
The spaces are only for clarity and not included in the syntax.
Fields within
[ ]
are optional.|
implies mutual exclusivity.If the
.
is present, then at least one ofv_align
andheight
must be present.width
andheight
are in units of columns and lines repectively.If the padding width or padding height is less than or equal to the image’s rendered width or rendered height respectively, the padding has no effect.
h_align
: This can be one of:<
→ left|
→ center>
→ rightabsent → center
width
: Integer padding width (default: terminal width minus horizontal allowance)Must not be greater than the terminal width.
v_align
: This can be one of:^
→ top-
→ middle_
→ bottomabsent → middle
height
: Integer padding height (default: terminal height minus vertical allowance)Must not be greater than the terminal height for animated images.
#
: Transparency setting:If absent, transparency is enabled.
threshold
: Alpha ratio above which pixels are taken as opaque e.g.0
,.325043
,.99999
. The value must be in the range 0.0 <= threshold < 1.0.bgcolor
: Hex color with which transparent background should be replaced e.gffffff
,7faa52
.If neither
threshold
norbgcolor
is present, but#
is present, transparency is disabled (uses the image’s default background color).
See Formatted rendering for examples.