wijjit.tags.display.ImageViewExtension

class wijjit.tags.display.ImageViewExtension(environment)[source]

Jinja2 extension for {% imageview %} tag.

Displays an image in the terminal using colored block characters.

Syntax:

{% imageview src="path/to/image.png" width=40 %}{% endimageview %}
{% imageview src=state.image_data height=20 mode="quadrant" %}{% endimageview %}
{% imageview src="photo.jpg" width="50%" height="fill" %}{% endimageview %}
{% imageview src="logo.png" mode="braille" threshold=90 %}{% endimageview %}
{% imageview src="logo.png" mode="braille" invert=True %}{% endimageview %}
Parameters:

src: Image source (file path, bytes, or PIL Image) width: Display width (int, “auto”, “fill”, or “50%”) height: Display height (int, “auto”, “fill”, or “50%”) mode: “color” (half-block), “quadrant”, or “braille” (default: “color”) threshold: Braille binarization cutoff, 0-255 or “auto” (default: “auto”) invert: Invert threshold in braille mode (default: False) background: Background RGB tuple for transparency (default: (0,0,0))

Parameters:

environment (Environment)

__init__(environment)
Parameters:

environment (Environment)

Return type:

None

Methods

__init__(environment)

attr(name[, lineno])

Return an attribute node for the current extension.

bind(environment)

Create a copy of this extension bound to another environment.

call_method(name[, args, kwargs, dyn_args, ...])

Call a method of the extension.

filter_stream(stream)

It's passed a TokenStream that can be used to filter tokens returned.

parse(parser)

Parse the imageview tag.

preprocess(source, name[, filename])

This method is called before the actual lexing and can be used to preprocess the source.

Attributes

identifier

priority

the priority of that extension.

tags

if this extension parses this is the list of tags it's listening to.

tags: t.Set[str] = {'imageview'}

if this extension parses this is the list of tags it’s listening to.

parse(parser)[source]

Parse the imageview tag.

Parameters:

parser (jinja2.parser.Parser) – Jinja2 parser

Returns:

Parsed node tree

Return type:

jinja2.nodes.CallBlock

identifier: t.ClassVar[str] = 'wijjit.tags.display.ImageViewExtension'