MkBinaryImage
Image carrying the data by itself.¶
Description
This node basically is a regular image link, but carries the image data by itself. The data will get written to the "virtual" folder at the end of the process. It can hold either str or bytes as data.
Example: From data¶
Jinja
{% set svg = '<svg width="90pt" height="90pt" version="1.1" viewBox="0 0 15.875 10.583" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="#F00" stroke-width=".3">
<path d="m6.1295 3.6601 3.2632 3.2632z"/>
<path d="m9.3927 3.6601-3.2632 3.2632z"/>
</g>
</svg>' %}
{{ svg | MkBinaryImage(path="some_image.svg", caption="A simple cross") }}
Python
MkBinaryImage(
'<svg width="90pt" height="90pt" version="1.1" viewBox="0 0 15.875 10.583" xmlns="http://www.w3.org/2000/svg">\n <g fill="none" stroke="#F00" stroke-width=".3">\n <path d="m6.1295 3.6601 3.2632 3.2632z"/>\n <path d="m9.3927 3.6601-3.2632 3.2632z"/>\n </g>\n </svg>',
"some_image.svg",
caption="A simple cross",
)
Example: From icon¶
Python
MkBinaryImage(
'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M13 9h5.5L13 3.5zM6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m0 18h12v-8l-4 4l-2-2zM8 9a2 2 0 0 0-2 2a2 2 0 0 0 2 2a2 2 0 0 0 2-2a2 2 0 0 0-2-2"/></svg>',
"file_image.svg",
width=200,
)
Bases: MkImage
__init__
¶
__init__(
data: bytes | str,
path: str,
*,
target: LinkableType | None = None,
caption: str = "",
title: str = "",
align: Literal["left", "right"] | None = None,
width: int | None = None,
**kwargs: Any
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
bytes | str
|
Image data |
required |
path
|
str
|
path for the image (including extension) |
required |
target
|
LinkableType | None
|
Optional URL or node the image should link to |
None
|
caption
|
str
|
Image caption |
''
|
title
|
str
|
Image title |
''
|
align
|
Literal['left', 'right'] | None
|
Image alignment |
None
|
width
|
int | None
|
Image width in pixels |
None
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
for_file
classmethod
¶
Name | Children | Inherits |
---|---|---|
MkImage mknodes.basenodes.mkimage Image including optional caption. |
graph TD
94596169149632["mkbinaryimage.MkBinaryImage"]
94596170208544["mkimage.MkImage"]
94596169136704["mknode.MkNode"]
94596171773984["node.Node"]
139930746687680["builtins.object"]
94596170208544 --> 94596169149632
94596169136704 --> 94596170208544
94596171773984 --> 94596169136704
139930746687680 --> 94596171773984
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mkbinaryimage/metadata.toml
[metadata]
icon = "mdi:file-image"
name = "MkBinaryImage"
group = "image"
[examples.from_data]
title = "From data"
jinja = """
{% set svg = '<svg width="90pt" height="90pt" version="1.1" viewBox="0 0 15.875 10.583" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="#F00" stroke-width=".3">
<path d="m6.1295 3.6601 3.2632 3.2632z"/>
<path d="m9.3927 3.6601-3.2632 3.2632z"/>
</g>
</svg>' %}
{{ svg | MkBinaryImage(path="some_image.svg", caption="A simple cross") }}
"""
[examples.from_icon]
title = "From icon"
jinja = """
{{ mk.MkBinaryImage.for_icon("file-image", width=200) }}
"""