Reference
Top-Level Functions
- term_image.get_font_ratio()
Returns the set libray-wide font ratio.
- Return type
float
- term_image.set_font_ratio(ratio)
Sets the library-wide font ratio.
- Parameters
ratio (float) – The aspect ratio (i.e width / height) of a character cell in the
emulator. (terminal) –
- Return type
None
This value is taken into consideration when setting image sizes 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.
Important
Changing the font ratio does not automatically affect any image whose size has already been set. For a change in font ratio to have any effect, it’s size has to be set again.
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)v_align
: This can be one of:^
→ top-
→ middle_
→ bottomabsent → middle
height
: Integer padding height (default: terminal height minus vertical allowance)#
: 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.