libvt.graphics

Zero-dependency sans-I/O SIXEL and Kitty APC G placement tracker.

class libvt.graphics.GraphicsProtocol
class libvt.graphics.GraphicsProtocol

Bases: StrEnum

Terminal graphics protocol family.

class libvt.graphics.GraphicsTracker
class libvt.graphics.GraphicsTracker

Bases: object

Per-screen sans-I/O SIXEL and Kitty APC G state machine.

class libvt.graphics.ImageMeta
class libvt.graphics.ImageMeta

Bases: object

Stored sans-I/O image metadata without buffered pixel bitmaps.

class libvt.graphics.ImagePlacement
class libvt.graphics.ImagePlacement

Bases: object

Immutable snapshot of a SIXEL or Kitty image placement on a screen.

class libvt.graphics.ZLayer
class libvt.graphics.ZLayer

Bases: StrEnum

Kitty graphics z-ordering plane relative to cell background and text.

libvt.graphics.extract_png_dimensions(header_bytes)
function[source]
function[source]
libvt.graphics.extract_png_dimensions(header_bytes)

Extract (width_px, height_px) from the first 24 bytes of a PNG stream.

Parameters:

header_bytes (bytes) – Leading uncompressed bytes of a PNG payload (at least 24 bytes).

Returns:

(width_px, height_px) when the PNG signature and IHDR chunk header are valid and positive, else None.

Return type:

tuple[int, int] | None

libvt.graphics.scan_sixel_geometry(payload, *, max_dimension=10000)
function[source]
function[source]
libvt.graphics.scan_sixel_geometry(payload, *, max_dimension=10000)

Compute (width_px, height_px) of a SIXEL payload in O(n) time.

Parameters:
  • payload (bytes) – Raw SIXEL data stream following DCS Ps... q.

  • max_dimension (int) – Upper bound applied to raster attributes and !Pn repeat counts.

Returns:

Clamped (width_px, height_px) in pixels.

Return type:

tuple[int, int]