encode static method

String encode(
  1. Image image, {
  2. String? name,
  3. int? columns,
  4. int? rows,
  5. bool preserveAspectRatio = true,
})

Encodes an image into iTerm2 Image Protocol escape sequences.

The image is first encoded as PNG internally.

image is the image to encode. name is an optional filename for the image. columns is the number of terminal columns the image should occupy. rows is the number of terminal rows the image should occupy. preserveAspectRatio whether to preserve aspect ratio (default true).

Returns a string containing the escape sequences to display the image.

Implementation

static String encode(
  img.Image image, {
  String? name,
  int? columns,
  int? rows,
  bool preserveAspectRatio = true,
}) {
  // iTerm2 expects a standard image format (like PNG) base64 encoded.
  final pngBytes = img.encodePng(image);
  return encodePng(
    pngBytes,
    name: name,
    columns: columns,
    rows: rows,
    preserveAspectRatio: preserveAspectRatio,
  );
}