scistag.vislog.visual_image_logger.VisualImageLogger

class VisualImageLogger(log_builder)[source]

Bases: object

Helper class for storing images in a VisualLog

Parameters

log_builder (VisualLogBuilder) – The log builder object we are logging with

Methods

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

log

The log we are logging to

builder

The log builder we are using to write data

__call__(source, name=None, alt_text=None, pixel_format=None, download=False, scaling=1.0, max_width=None, optical_scaling=1.0, html_linebreak=True)[source]

Adds an image to the log.

Parameters
  • name (str | None) – The name of the image under which it shall be stored on disk (in case write_to_disk is enabled).

  • source (Image | Canvas | str | bytes | np.ndarray) – The data object, e.g. an scitag.imagestag.Image, a numpy array, an URL or a FileStag compatible link.

  • alt_text (str | None) – An alternative text if no image can be displayed

  • pixel_format (Optional['PixelFormat'] | str | None) – The pixel format (in case the image is passed as numpy array). By default gray will be used for single channel, RGB for triple band and RGBA for quad band sources.

  • download (bool) – Defines if an image shall be downloaded

  • scaling (float) – The factor by which the image shall be scaled

  • max_width (int | float | None) –

    Defines if the image shall be scaled to a given size.

    Possible values - True = Scale to the log’s max_fig_size. - float = Scale the image to the defined percentual size of the

    max_fig_size, 1.0 = max_fig_size

  • optical_scaling (float) – Defines the factor with which the image shall be visualized on the html page without really rescaling the image itself and thus giving the possibility to zoom in the browser.

  • html_linebreak – Defines if a linebreak shall be inserted after the image.

static _build_get_embedded_image(source)[source]

Encodes an image to ASCII to embed it directly into an HTML page

Parameters

source (bytes) – The source data

Return type

str

Returns

The string to embed

_insert_image_reference(name, source, alt_text, scaling=1.0, max_width=None, html_scaling=1.0, html_linebreak=True)[source]

Inserts a link to an image in the html logger without actually downloading or storing the image locally

Parameters
  • name – The image’s name

  • source – The url

  • alt_text – The alternative display text

  • scaling (float) – The scaling factor

  • max_width (int | None) – The image’s maximum width in pixels

  • html_scaling (float) – Defines the factor with which the image shall be visualized on the html page without really rescaling the image itself and thus giving the possibility to zoom in the browser.

  • html_linebreak (bool) – Defines if a linebreak shall be inserted after the image

_log_image_to_disk(filename, name, source, encoded_image)[source]

Stores an image on the disk

Parameters
  • filename (str) – The output filename

  • name (str) – The image’s name

  • source (bytes | Image) – The data source

  • encoded_image – The encoded image

Return type

str

Returns

The file location of the store image

_need_to_store_images_on_disk()[source]

Returns if images NEED to be stored on disk

Return type

bool

Returns

True if they do

builder: VisualLogBuilder

The log builder we are using to write data

log: VisualLog

The log we are logging to