Sixel icon indicating copy to clipboard operation
Sixel copied to clipboard

Enhancement: Add Support for Icon Files (.ico)

Open benzaria opened this issue 1 year ago β€’ 3 comments

Currently, the Sixel module supports image formats like PNG, JPG, and others, but it lacks support for .ico (icon) files.

i managed to do that by this ps1 script:

$image = [System.Drawing.Image]::FromFile($resolvedPath)
$tempDir = [System.IO.Path]::GetTempPath()
$tempPngPath = Join-Path $tempDir ("icon_" + [System.IO.Path]::GetFileNameWithoutExtension($ImagePath) + ".png")

$image.Save($tempPngPath, [System.Drawing.Imaging.ImageFormat]::Png)
$image.Dispose()
ConvertTo-Sixel $tempPngPath -Protocol Sixel
del $tempPngPath -Force

but it will better to have a native integration in the module.

one more thing just optional if u want, what about also the ability to display icons from exe files !? this is a simple example

$icon = [System.Drawing.Icon]::ExtractIcon($exePath, 0, 1024) # or 256 its faster
$icon.ToBitmap().Save($icoPath, [System.Drawing.Imaging.ImageFormat]::Png)

benzaria avatar Mar 10 '25 12:03 benzaria

Hey!

Thanks for the suggestion

Uhm, I'm a bit hesitant to add System.Drawing into the module mostly because of cross-platform support system.drawing#remarks

Also it seems that .ico will be supported in Sixlabors v4.

But i have actually been tinkering with something that could help, in my testing branch i've added the -Stream parameter so you wouldn't need to save the file atleast.

$image = [System.Drawing.Image]::FromFile($ico)
$stream = [System.IO.MemoryStream]::new()
$image.Save($stream, [System.Drawing.Imaging.ImageFormat]::Png)
ConvertTo-Sixel -Stream $stream

$icon = [System.Drawing.Icon]::ExtractAssociatedIcon($resolvedpath)
$stream = [System.IO.MemoryStream]::new()
$icon.ToBitmap().Save($stream, [System.Drawing.Imaging.ImageFormat]::Png)
ConvertTo-Sixel -Stream $stream

I'll try and get out the new release soon.

trackd avatar Mar 10 '25 16:03 trackd

Hey!

Thanks for the detailed response! I completely understand the concerns about System.Drawing and cross-platform compatibility (which I wasn't knowing about πŸ˜…). It’s great to hear that .ico support is coming in SixLabors that should make things much smoother!

The -Stream parameter sounds like an awesome improvement! Not having to save temporary files makes things cleaner and more efficient. Looking forward to testing it out when the new release drops.

Appreciate the work you're putting into this keep up the great work! πŸš€

benzaria avatar Mar 15 '25 23:03 benzaria

The new version of the module is out now!

-Stream is available there, as well as support for Windows Powershell 5.1.

the module should automatically support .ico's as soon as Sixlabor releases it (and i update the library)

But until then theres not much i can do, i'll close this issue for now.

Thanks!

trackd avatar Mar 19 '25 00:03 trackd