Skip to content

Instantly share code, notes, and snippets.

@pinecones-sx
Created October 16, 2018 20:44
Show Gist options
  • Save pinecones-sx/450cd6fef9e1eb3da7ae1cfdd209fe7f to your computer and use it in GitHub Desktop.
Save pinecones-sx/450cd6fef9e1eb3da7ae1cfdd209fe7f to your computer and use it in GitHub Desktop.
Powershell script to extract HQ icons
<# Extract-Icons
Requires iconsext.exe from:
http://www.nirsoft.net/utils/iconsext.html
No documentation because I'm lazy.
I needed something to extract high resolution icons and couldn't find a definite
answer so i just reused a CMD compatible free program.
#>
$env:uncExtractorEXE = ''
If (-not $env:uncExtractorEXE){$env:uncExtractorEXE = Join-Path $PSScriptRoot 'iconsext.exe'}
function global:Extract-Icons{
param(
[System.IO.FileInfo]$TargetFile,
[System.IO.DirectoryInfo]$OutputFolder,
[System.IO.FileInfo]$EXELocation = $env:uncExtractorEXE
)
# Verify files exist
$existsEXELocation = Test-Path $EXELocation
$existsTargetFile = Test-Path $TargetFile
$existsOutputFolder = Test-Path $OutputFolder
If ($existsOutputFolder){
# Make sure this is a directory
$existsOutputFolder = $OutputFolder.Attributes -like '*Directory*'
}
If ($existsTargetFile -and $existsOutputFolder -and $existsEXELocation){
# iconsext.exe /save "source file" "save folder" [-icons] [-cursors] [-asico]
$argsExtractor = (
'/save' + ' ' +
'"' + $TargetFile + '"' + ' ' +
'"' + $OutputFolder + '"' + ' ' +
'-Icons'
)
# Extract the icons!
$null = Start-Process -FilePath $env:uncExtractorEXE -ArgumentList $argsExtractor -Wait
}
Else{
# Throw out an error for what went wrong.
If (-not $existsTargetFile){Throw ('Target file "' + $TargetFile.FullName + '" does not exist.')}
ElseIf (-not $existsOutputFolder){Throw ('Output folder "' + $OutputFolder.FullName + '" does not exist.')}
ElseIf (-not $existsEXELocation){Throw ('Executible file "' + $EXELocation.FullName + '" does not exist.')}
Else{Throw 'Nondescript error.'}
}
}
@pinecones-sx
Copy link
Author

and this produces non GDI+ friendly images. =,(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment