Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ output/*
output
.vs/*
!assets/*.png
test_alc.ps1
testimages.ps1
testimages/*
*.ps1
testdata/*
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# Sixel

A module that lets you convert images to Sixel, Inline Images Protocol, Kitty Graphics Protocol.
A module that lets you convert images to Sixel, Inline Images Protocol, Kitty Graphics Protocol.

Supports converting bmp, gif, jpeg, pbm, png, tiff, tga, webp to sixel.

This code was originally meant to be added to [PwshSpectreConsole](https://github.com/ShaunLawrie/PwshSpectreConsole)
But we wanted to get something out quickly for people who wanted to test sixel.

It uses an Assembly load context for the Sixlabors library, from [PowerShell-ALC](https://github.com/jborean93/PowerShell-ALC)

## Install

```powershell
Expand All @@ -19,10 +14,8 @@ Install-PSResource Sixel

## Requirements

This module requires Powershell version 7.4+
We test against the latest Windows Terminal Preview.

Sixel support has not been added to Windows Terminal Stable branch yet.
This module supports Powershell version 5.1 & 7.4.
Windows Terminal supports Sixel from version 1.22.

There is an example sixel file in the ./assets folder that can be used for testing

Expand All @@ -36,15 +29,13 @@ Invoke-RestMethod https://raw.githubusercontent.com/trackd/Sixel/refs/heads/main
**[@trackd](https://github.com/trackd)**
**[@ShaunLawrie](https://github.com/ShaunLawrie)**

## Todo
## Libraries

1. Better docs/help
2. Tests
3. Animated sixels
- [Sixlabors.Imagesharp](https://github.com/SixLabors/ImageSharp) [Apache2.0](https://github.com/SixLabors/ImageSharp/blob/main/LICENSE)

## libraries
## ALC

[Sixlabors.Imagesharp](https://github.com/SixLabors/ImageSharp)
[PowerShell-ALC](https://github.com/jborean93/PowerShell-ALC)

## examples

Expand Down
36 changes: 29 additions & 7 deletions docs/en-US/ConvertTo-Sixel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@ schema: 2.0.0

## SYNOPSIS

Converts an image to sixel
Converts an image to Sixel, Kitty, InlineImage or Ascii Blocks as fallback.

## SYNTAX

### ByPath (Default)
### Path (Default)

```powershell
ConvertTo-Sixel [-Path] <string> [-MaxColors <int>] [-Width <int>] [-Force] [<CommonParameters>]
```

### ByUrl
### Url

```powershell
ConvertTo-Sixel -Url <string> [-MaxColors <int>] [-Width <int>] [-Force] [<CommonParameters>]
ConvertTo-Sixel -Url <uri> [-MaxColors <int>] [-Width <int>] [-Force] [<CommonParameters>]
```

### Stream

```powershell
ConvertTo-Sixel -Stream <Stream> [-MaxColors <int>] [-Width <int>] [-Force] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -70,7 +76,7 @@ Accept wildcard characters: False
A URL of the image to download and convert to sixel.

```yaml
Type: String
Type: Uri
Parameter Sets: Url
Aliases: Uri

Expand All @@ -81,6 +87,22 @@ Accept pipeline input: True
Accept wildcard characters: False
```

### -Stream

A stream of an image.

```yaml
Type: Stream
Parameter Sets: Stream
Aliases: FileStream, InputStream, ImageStream, ContentStream

Required: True
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False
```

### -MaxColors

The maximum number of colors to use in the image.
Expand Down Expand Up @@ -133,7 +155,7 @@ Accept wildcard characters: False
### -Protocol

Select the image protocol to output.
Supports Sixel, InlineImageProtocol, KittyGraphicsProtocol
Supports Sixel, InlineImageProtocol, KittyGraphicsProtocol, Block

It will attempt to autoselect the supported image protocol for your terminal.

Expand All @@ -153,7 +175,7 @@ Accept wildcard characters: False

### System.String

Path or url to an image file
Path, url, Stream of an image file

## OUTPUTS

Expand Down
67 changes: 44 additions & 23 deletions docs/en-US/ConvertTo-SixelGif.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ schema: 2.0.0

## SYNOPSIS

Converts a gif to a sixel animation
Converts a gif to a sixel animation.

this cmdlet only supports Sixel.

## SYNTAX

### ByPath (Default)
### Path (Default)

```powershell
ConvertTo-SixelGif [-Path] <string> [-MaxColors <int>] [-Width <int>] [-Force] [-LoopCount <int>] [<CommonParameters>]
```

### ByUrl
### Url

```powershell
ConvertTo-SixelGif -Url <uri> [-MaxColors <int>] [-Width <int>] [-Force] [-LoopCount <int>] [<CommonParameters>]
```

### Stream

```powershell
ConvertTo-SixelGif -Url <string> [-MaxColors <int>] [-Width <int>] [-Force] [-LoopCount <int>] [<CommonParameters>]
ConvertTo-SixelGif -Stream <stream> [-MaxColors <int>] [-Width <int>] [-Force] [-LoopCount <int>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -68,7 +76,7 @@ Accept wildcard characters: False
A URL of the gif to download and convert to sixel.

```yaml
Type: String
Type: Uri
Parameter Sets: Url
Aliases: Uri

Expand All @@ -79,10 +87,25 @@ Accept pipeline input: True
Accept wildcard characters: False
```

### -MaxColors
### -Stream

The maximum number of colors to use in the image.
Max is 256.
A stream of an image.

```yaml
Type: Stream
Parameter Sets: Stream
Aliases: FileStream, InputStream, ImageStream, ContentStream

Required: True
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False
```

### -LoopCount

The amount of times the gif will loop.

```yaml
Type: int
Expand All @@ -91,35 +114,36 @@ Aliases: None

Required: False
Position: Named
Default value: 256
Default value: 3
Accept pipeline input: False
Accept wildcard characters: False
```

### -Width
### -MaxColors

Width of the image in character cells, the height will be scaled to maintain aspect ratio.
The maximum number of colors to use in the image.
Max is 256.

```yaml
Type: int
Parameter Sets: (All)
Aliases: CellWidth
Aliases: None

Required: False
Position: Named
Default value: None
Default value: 256
Accept pipeline input: False
Accept wildcard characters: False
```

### -Force
### -Width

Force the command to attempt to output sixel data even if the terminal does not support sixel.
Width of the image in character cells, the height will be scaled to maintain aspect ratio.

```yaml
Type: SwitchParameter
Type: int
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -128,15 +152,12 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Protocol

Select the image protocol to output.
Supports Sixel, InlineImageProtocol, KittyGraphicsProtocol
### -Force

It will attempt to autoselect the supported image protocol for your terminal.
Force the command to attempt to output sixel data even if the terminal does not support sixel.

```yaml
Type: ImageProtocol
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Expand Down
43 changes: 24 additions & 19 deletions module/Sixel.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@
# Generated on: 2024-10-09

@{
RootModule = 'Sixel.psm1'
ModuleVersion = '0.3.0'
CompatiblePSEditions = 'Core'
PowerShellVersion = '7.4'
GUID = '95f4627c-f8f5-43d5-824b-4c356737f87b'
Author = 'trackd, ShaunLawrie'
Copyright = '(c) trackd. All rights reserved.'
Description = '@
RootModule = 'Sixel.psm1'
ModuleVersion = '0.4.0'
CompatiblePSEditions = @('Desktop', 'Core')
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
ClrVersion = '4.0'
GUID = '95f4627c-f8f5-43d5-824b-4c356737f87b'
Author = 'trackd, ShaunLawrie'
Copyright = '(c) trackd. All rights reserved.'
Description = '
Display images in the terminal using various protocols

✔️ Sixel
- requires Windows Terminal v1.22+
- Gif support using ConvertTo-SixelGif
- Gif support using ConvertTo-SixelGif.
✔️ Inline Image Protocol
- Supported by VSCode, xterm2, WezTerm, and others.
✔️ Kitty Graphics Protocol
- Supported by Kitty terminal.
✔️ Block cells
- Fallback to block cells if no image protocol is supported.
@'
CmdletsToExport = 'ConvertTo-Sixel', 'ConvertTo-SixelGif'
AliasesToExport = 'cts','gif'
FormatsToProcess = 'Sixel.format.ps1xml'
PrivateData = @{

Note: Sixel requires Windows Terminal v1.22+ or VSCode Insiders.
'
CmdletsToExport = 'ConvertTo-Sixel', 'ConvertTo-SixelGif'
AliasesToExport = 'cts', 'gif'
FormatsToProcess = 'Sixel.format.ps1xml'
PrivateData = @{
PSData = @{
Tags = @(
'Sixel',
Expand All @@ -40,16 +43,18 @@
)
LicenseUri = 'https://github.com/trackd/Sixel/blob/main/LICENSE'
ProjectUri = 'https://github.com/trackd/Sixel'
# Prerelease = 'prerelease01'
ReleaseNotes = @'
0.3.0 - Added GIF support, added Ascii art using halfblock cells.
0.4.0 - Added support for Windows Powershell 5.1, added parameter -Stream as input.
0.3.1 - Added GIF support, added Ascii art using halfblock cells.
0.2.5 - bugfix, cleanup, added experimental support for inline image protocol and Kitty Graphics Protocol.
0.2.0 - Added better scaling, changes -Width to use cell width instead.
0.1.0 - Initial release.
'@
}
}
# A missing or $null entry is equivalent to specifying the wildcard *. declare unused with @() for better perf.
FunctionsToExport = @()
VariablesToExport = @()
TypesToProcess = @()
FunctionsToExport = @()
VariablesToExport = @()
TypesToProcess = @()
}
Loading