Package org.aesh.terminal.image
Class KittyImage
java.lang.Object
org.aesh.terminal.image.KittyImage
- All Implemented Interfaces:
TerminalImage
Kitty graphics protocol implementation.
Protocol format:
ESC _ G [key=value,...] ; [payload] ESC \
The protocol uses APC (Application Program Command) escape sequences. Large images are split into multiple chunks of up to 4096 bytes.
Key control parameters:
- a=t|T|p|d|f - action (transmit, put, delete, frame)
- f=24|32|100 - format (RGB, RGBA, PNG)
- t=d|f|t|s - transmission medium (direct, file, temp, shared memory)
- s=N - source width in pixels
- v=N - source height in pixels
- c=N - display columns
- r=N - display rows
- m=0|1 - more data follows (for chunked transfer)
- q=1|2 - suppress responses
Supported by: Kitty, Konsole (partial)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionencode()Encode the image as an escape sequence string ready to be written to the terminal.static KittyImagefromBytes(byte[] data) Create a Kitty image from raw bytes.static KittyImageCreate a Kitty image from a file.intGet the display height in terminal cells.Get the protocol used by this image.intGet the display width in terminal cells.heightCells(int cells) Set the display height in terminal cells (rows).sourceDimensions(int width, int height) Set the source image dimensions.suppressResponse(boolean suppress) Set whether to suppress terminal responses.widthCells(int cells) Set the display width in terminal cells (columns).zIndex(int zIndex) Set the z-index for layering multiple images.
-
Constructor Details
-
KittyImage
public KittyImage(byte[] imageData) Create a Kitty image from image data.Supports PNG, JPEG, GIF, and other formats supported by Java ImageIO. Non-PNG images are automatically converted to PNG format since the Kitty graphics protocol only supports PNG for compressed images.
- Parameters:
imageData- the image data (PNG, JPEG, GIF, etc.)
-
-
Method Details
-
fromFile
Create a Kitty image from a file.Supports PNG, JPEG, GIF, and other formats supported by Java ImageIO. Non-PNG images are automatically converted to PNG.
- Parameters:
path- path to the image file- Returns:
- the terminal image
- Throws:
IOException- if the file cannot be read
-
fromBytes
Create a Kitty image from raw bytes.Supports PNG, JPEG, GIF, and other formats supported by Java ImageIO. Non-PNG images are automatically converted to PNG.
- Parameters:
data- the image data- Returns:
- the terminal image
-
widthCells
Set the display width in terminal cells (columns).- Parameters:
cells- number of columns- Returns:
- this image for chaining
-
heightCells
Set the display height in terminal cells (rows).- Parameters:
cells- number of rows- Returns:
- this image for chaining
-
sourceDimensions
Set the source image dimensions. Required for raw RGB/RGBA data, optional for PNG.- Parameters:
width- source width in pixelsheight- source height in pixels- Returns:
- this image for chaining
-
zIndex
Set the z-index for layering multiple images. Higher z-index images appear on top.- Parameters:
zIndex- the z-index value- Returns:
- this image for chaining
-
suppressResponse
Set whether to suppress terminal responses. Default is true to avoid cluttering input.- Parameters:
suppress- true to suppress responses- Returns:
- this image for chaining
-
encode
Description copied from interface:TerminalImageEncode the image as an escape sequence string ready to be written to the terminal.- Specified by:
encodein interfaceTerminalImage- Returns:
- the escape sequence that will display the image
-
getProtocol
Description copied from interface:TerminalImageGet the protocol used by this image.- Specified by:
getProtocolin interfaceTerminalImage- Returns:
- the image protocol
-
getWidthCells
public int getWidthCells()Description copied from interface:TerminalImageGet the display width in terminal cells. Returns -1 if width is auto-detected or not specified.- Specified by:
getWidthCellsin interfaceTerminalImage- Returns:
- width in cells, or -1 for auto
-
getHeightCells
public int getHeightCells()Description copied from interface:TerminalImageGet the display height in terminal cells. Returns -1 if height is auto-detected or not specified.- Specified by:
getHeightCellsin interfaceTerminalImage- Returns:
- height in cells, or -1 for auto
-