Package org.aesh.terminal.image
Class ITermImage
java.lang.Object
org.aesh.terminal.image.ITermImage
- All Implemented Interfaces:
TerminalImage
iTerm2 inline images protocol implementation.
Protocol format:
ESC ] 1337 ; File = [arguments] : base64_data BEL
Supported arguments:
- name=base64_filename - base64 encoded filename
- size=N - file size in bytes
- width=N or width=Npx or width=N% - display width
- height=N or height=Npx or height=N% - display height
- preserveAspectRatio=0|1 - whether to preserve aspect ratio
- inline=1 - display inline (required for display)
Supported by: iTerm2, WezTerm, Mintty, VSCode terminal, Tabby, Hyper
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionITermImage(byte[] imageData, String filename) Create an iTerm2 image from raw image data. -
Method Summary
Modifier and TypeMethodDescriptionencode()Encode the image as an escape sequence string ready to be written to the terminal.static ITermImagefromBytes(byte[] data) Create an iTerm2 image from raw bytes.static ITermImageCreate an iTerm2 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.heightPercent(int percent) Set the display height as a percentage of the terminal height.heightPixels(int pixels) Set the display height in pixels.preserveAspectRatio(boolean preserve) Set whether to preserve the aspect ratio when resizing.useStTerminator(boolean useSt) Use ST (ESC \) terminator instead of BEL.widthCells(int cells) Set the display width in terminal cells.widthPercent(int percent) Set the display width as a percentage of the terminal width.widthPixels(int pixels) Set the display width in pixels.
-
Constructor Details
-
ITermImage
Create an iTerm2 image from raw image data.- Parameters:
imageData- the image data (PNG, JPEG, GIF, etc.)filename- optional filename for the image
-
-
Method Details
-
fromFile
Create an iTerm2 image from a file.- Parameters:
path- path to the image file- Returns:
- the terminal image
- Throws:
IOException- if the file cannot be read
-
fromBytes
Create an iTerm2 image from raw bytes.- Parameters:
data- the image data- Returns:
- the terminal image
-
widthCells
Set the display width in terminal cells.- Parameters:
cells- number of cells- Returns:
- this image for chaining
-
heightCells
Set the display height in terminal cells.- Parameters:
cells- number of cells- Returns:
- this image for chaining
-
widthPixels
Set the display width in pixels.- Parameters:
pixels- width in pixels- Returns:
- this image for chaining
-
heightPixels
Set the display height in pixels.- Parameters:
pixels- height in pixels- Returns:
- this image for chaining
-
widthPercent
Set the display width as a percentage of the terminal width.- Parameters:
percent- percentage (1-100)- Returns:
- this image for chaining
-
heightPercent
Set the display height as a percentage of the terminal height.- Parameters:
percent- percentage (1-100)- Returns:
- this image for chaining
-
preserveAspectRatio
Set whether to preserve the aspect ratio when resizing.- Parameters:
preserve- true to preserve aspect ratio- Returns:
- this image for chaining
-
useStTerminator
Use ST (ESC \) terminator instead of BEL. Some terminals prefer ST over BEL.- Parameters:
useSt- true to use ST terminator- 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
-