winutil/functions/private/ConvertTo-Icon.ps1
Mr.k 1891ea7966
Remove trailing whitespace characters (#2149)
* Remove All Trailing Whitespace Characters in '.ps1' Files

* Remove All Trailing Whitespace Characters in '.json' Files

* Remove All Trailing Whitespace Characters in '.yaml' Files

* Remove All Trailing Whitespace Characters in Different Files

* Remove Even More Trailing Whitespace Characters
2024-06-28 17:15:39 -05:00

27 lines
771 B
PowerShell

function ConvertTo-Icon {
<#
.DESCRIPTION
This function will convert PNG to ICO file
.EXAMPLE
ConvertTo-Icon -bitmapPath "$env:TEMP\cttlogo.png" -iconPath $iconPath
#>
param( [Parameter(Mandatory=$true)]
$bitmapPath,
$iconPath = "$env:temp\newicon.ico"
)
Add-Type -AssemblyName System.Drawing
if (Test-Path $bitmapPath) {
$b = [System.Drawing.Bitmap]::FromFile($bitmapPath)
$icon = [System.Drawing.Icon]::FromHandle($b.GetHicon())
$file = New-Object System.IO.FileStream($iconPath, 'OpenOrCreate')
$icon.Save($file)
$file.Close()
$icon.Dispose()
#explorer "/SELECT,$iconpath"
}
else { Write-Warning "$BitmapPath does not exist" }
}