Skip to content

Instantly share code, notes, and snippets.

@yell0wsuit
Created February 8, 2024 04:10
Show Gist options
  • Save yell0wsuit/2708ae67da16bf4aa6db53e227a604ac to your computer and use it in GitHub Desktop.
Save yell0wsuit/2708ae67da16bf4aa6db53e227a604ac to your computer and use it in GitHub Desktop.
Generate favicon for website on Windows
@echo off
setlocal enabledelayedexpansion
set IMAGE=favicon.png
set OUTPUT=favicon.ico
set SIZES=16 32 64 128 192 256
:: Create a temporary directory for resized images
set TEMP_DIR=%~dp0temp_ico
mkdir "!TEMP_DIR!"
:: Resize the image to each size and save temporarily
for %%s in (%SIZES%) do (
magick "!IMAGE!" -resize %%sx%%s "!TEMP_DIR!\%%s.png"
)
:: Combine all resized images into a single ICO file
magick "!TEMP_DIR!\*.png" "!OUTPUT!"
:: Clean up the temporary directory
rd /s /q "!TEMP_DIR!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment