scistag.imagestag.ascii_image.AsciiImage

class AsciiImage(image, method=AsciiImageMethod.GRAY_LEVELS_10, max_width=80, **params)[source]

Bases: object

Helper class for converting images from RGB to ASCII, e.g. for being able to add images to text-only logs and to provide at least a coarse “preview” of the real image.

Parameters
  • image (Image) – The input image

  • max_width – The maximum characters per row

  • params – Advanced parameters

Methods

convert

Converts the whole image from pixles to ASCII characters

convert_row

Converts a single row from pixels to characters

get_ascii

Returns the converted image :rtype: str :return:

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

image

The image to be converted

max_width

The maximum character count per row

ascii_image

The ASCII representation of the image after it's conversion

scaled_image

The scaled image

is_converted

Defines if the conversion was executed already

dictionary

The conversion dictionary to use

convert()[source]

Converts the whole image from pixles to ASCII characters

Return type

AsciiImage

Returns

Self

convert_row(pixels)[source]

Converts a single row from pixels to characters

Parameters

pixels (ndarray) – The pixel data

Return type

str

Returns

The characters

get_ascii()[source]

Returns the converted image :rtype: str :return:

ascii_image: str

The ASCII representation of the image after it’s conversion

dictionary

The conversion dictionary to use

image

The image to be converted

is_converted

Defines if the conversion was executed already

max_width

The maximum character count per row

scaled_image: Image | None

The scaled image