Skip to content

Get-SpectreImage

Description

Displays an image in the console using CanvasImage or SixelImage if the terminal supports Sixel.
The image can be resized to a maximum width if desired.

Windows Terminal supports Sixel in the latest preview builds so it will be available in the production builds soon 🤞
See https://www.arewesixelyet.com/ for Sixel support status for your terminal.


Examples

Example 1
When Sixel is not supported the image will use the standard Canvas renderer which draws the image using character cells to represent the image.

Terminal window
Get-SpectreImage -ImagePath ".\private\images\smiley.png" -MaxWidth 40

Example 2
For Sixel images, the image returned by Get-SpectreImage will render a new frame every time it’s drawn so if it’s an animated GIF it will appear animated if you render it repeatedly and move the cursor back to the same start position before each image output.

Spectre Sixel Example

Terminal window
$image = Get-SpectreImage ".\private\images\lapras-pokemon.gif" -MaxWidth 50
Clear-Host
[Console]::CursorVisible = $false
for($frame = 0; $frame -lt 100; $frame++) {
[Console]::SetCursorPosition(0, 0)
$image | Format-SpectrePanel -Title "Frame: $frame" -Color White | Out-SpectreHost
Start-Sleep -Milliseconds 150
}

Parameters

ImagePath

The path to the image file to be displayed, as a local path or remote path using http/https.

TypeRequiredPositionPipelineInput
[String]false1false

MaxWidth

The maximum width of the image. If not specified, the image will be displayed at its original size.

TypeRequiredPositionPipelineInput
[Int32]false2false

Format

The preferred format to use when rendering the image.
If not specified, the image will be rendered using Sixel if the terminal supports it, otherwise it will use Canvas.

Valid Values:

  • Auto
  • Sixel
  • Canvas
TypeRequiredPositionPipelineInput
[String]false3false

Syntax

Terminal window
Get-SpectreImage [[-ImagePath] <String>] [[-MaxWidth] <Int32>] [[-Format] <String>] [<CommonParameters>]