This PowerShell script converts an image (in formats such as SVG) into a multi-size ICO icon. The script uses Inkscape to generate PNG images at different resolutions and ImageMagick to combine these images into a single .ico
file. Temporary files created during the process are automatically cleaned up.
- Generates icons with multiple resolutions: 256x256, 128x128, 64x64, 48x48, 32x32, 24x24, and 16x16 pixels.
- Automatically finds
magick.exe
(ImageMagick) in the system'sPATH
or a common installation directory. - Uses Inkscape to handle SVG image conversion.
- Cleans up temporary files after conversion.
- Inkscape: The script uses Inkscape to export PNG files. You need to have Inkscape installed and accessible at the path
C:\Program Files\Inkscape\bin\inkscape.com
. Adjust the path if your installation is located elsewhere. - ImageMagick: The script uses ImageMagick’s
magick.exe
command to generate ICO files. It attempts to findmagick.exe
in your system'sPATH
. If not found, it falls back to a common installation path:C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe
.
- Input Image: The script takes a single image file (such as an SVG) as input.
- Generate PNGs: It uses Inkscape to generate PNGs in different sizes (256x256, 128x128, 64x64, 48x48, 32x32, 24x24, and 16x16 pixels).
- Create ICO: The script then uses ImageMagick to combine the PNG files into a single
.ico
file. - Clean-up: Finally, it cleans up the temporary directory where the PNG files were stored.
.\ConvertToIcon.ps1 -ImagePath <path_to_image_file>
.\ConvertToIcon.ps1 -ImagePath "C:\Images\logo.svg"
This command will convert the logo.svg
image into a .ico
file containing multiple resolutions, saved in the same directory as the original image.
-ImagePath
: The full path to the image file (SVG or another format supported by Inkscape).