File size: 1,209 Bytes
7e3630c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862182b
 
 
 
7e3630c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import type { Jimp } from "jimp";
import type { JSX } from "react";

export interface ImageProps {
  /**
   * The source URL, file path or ArrayBuffer of the image to render
   * Supports all image formats supported by jimp (JPEG, PNG, WebP, GIF, BMP, TIFF).
   */
  src: Parameters<typeof Jimp.read>[0];
  /** Width in terminal cells or a percentage */
  width: number | string;
  /** Height in terminal cells or a percentage */
  height: number | string;
  /** Alternative text displayed while loading or on error */
  alt?: string;
  /** Override pixel width for image scaling (default: resolved from width) */
  pixelWidth?: number;
  /** Override pixel height for image scaling (default: resolved from height) */
  pixelHeight?: number;
}

/**
 * Interface defining an image rendering protocol.
 *
 * Each protocol represents a different method of displaying images in the terminal,
 * such as ASCII art, Sixel graphics, Braille patterns, or Unicode half-blocks.
 *
 * @interface ImageProtocol
 */
export interface ImageProtocol {
  /** Unique identifier for this protocol */
  name: string;
  /** Function that renders the image using this protocol */
  render(props: ImageProps): JSX.Element | null;
}