Skip to content

Get-SpectreImageExperimental

Description

This function loads an image from a file and displays it in the console using block characters and ANSI escape codes. The image is scaled to fit within the specified maximum width while maintaining its aspect ratio. If the image is an animated GIF, each frame is displayed in sequence.
The images rendered by this experimental function are not handled by Spectre Console, it’s using a PowerShell script to render the image in a higher resolution than Spectre.Console does by using half-block characters.


Examples

Example 1
This example demonstrates how to display an animated image in the console that loops 4 times.

Terminal window
Get-SpectreImageExperimental -ImagePath ".\private\images\harveyspecter.gif" -LoopCount 4 -Width 82

Example 2
This example demonstrates how to display a static image in the console.

Terminal window
Get-SpectreImageExperimental -ImagePath ".\private\images\smiley.png" -Width 80

Parameters

ImagePath

The path to the image file to display.

TypeRequiredPositionPipelineInput
[String]false1false

ImageUrl

The URL to the image file to display. If specified, the image is downloaded to a temporary file and then displayed.

TypeRequiredPositionPipelineInput
[Uri]false2false

Width

The width of the image in characters. The image is scaled to fit within this width while maintaining its aspect ratio.

TypeRequiredPositionPipelineInput
[Int32]false3false

LoopCount

The number of times to repeat the animation. The default value is 0, which means the animation will repeat forever. Press ctrl-c to stop the animation.

TypeRequiredPositionPipelineInput
[Int32]false4false

Resampler

The resampling algorithm to use when scaling the image. Valid values are “Bicubic” and “NearestNeighbor”. The default value is “Bicubic”.

Valid Values:

  • Bicubic
  • NearestNeighbor
TypeRequiredPositionPipelineInput
[String]false5false

Syntax

Terminal window
Get-SpectreImageExperimental [[-ImagePath] <String>] [[-ImageUrl] <Uri>] [[-Width] <Int32>] [[-LoopCount] <Int32>] [[-Resampler] <String>] [<CommonParameters>]