scistag.imagestag.html_renderer.HtmlRenderer¶
- class HtmlRenderer[source]¶
Bases:
objectThe HtmlRenderer allows the conversion from HTML code to an image for example to create the thumbnail of a web page or to integrate HTML elements into a slide.
Important: Needs te optional imgkit module and wkhtmltopdf (https://wkhtmltopdf.org/)
Initializer
Methods
Returns a dummy image if not data is available
Renders the HTML code to an image
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
The rendered web page
- static _generate_html(bg_color, options)[source]¶
Generates the html data
- Parameters
bg_color – The background color
options – Generator options. See render
- Returns
The html code
- static _trim(image, transparent, trim_width=True, trim_height=False)[source]¶
Searches for the first and last non-empty rows and columns and reduces the image to the valid pixels.
- Parameters
image (
ndarray) – The original imagetransparent (
bool) – Defines if the image was transparent and the alpha channel can be usedtrim_width – Defines if the image shall be reduced horizontally
trim_height – Defines if the image shall be reduced vertically
- Return type
ndarray- Returns
The trimmed image
- static dummy_image()[source]¶
Returns a dummy image if not data is available
- Return type
- Returns
Dummy image in the current framework’s representation
- render(options=None)[source]¶
Renders the HTML code to an image
- Parameters
options (dict | None) –
One of the following optins can be provided: * html - The website’s full HTML code (if set body & style are
ignored)
- body - Only the website’s body. You can pass only the content
code or
the full <body> block
style - The site’s style configuration (head.style)
- width - The rendering width. Otherwise auto detected / clipped at
None by default.
- height - The rendering height. Otherwise auto detected / no
limitation. None by default.
- transparent - Defines if the page shall be rendered onto
transparent background so an RGBA image will be
created. False by default. * backgroundColor - The color as Color object. White by default. * trimWidth - Automatically reduce the image’s width if the full
extend is not used. True by default.
- trimHeight - Defines if the height shall be trimmed. False by
default
- Return type
- Returns
An image handle