Skip to content

Instantly share code, notes, and snippets.

@cyjake
Forked from ricardobeat/favicon.txt
Created December 3, 2013 02:31
Show Gist options
  • Save cyjake/7762956 to your computer and use it in GitHub Desktop.
Save cyjake/7762956 to your computer and use it in GitHub Desktop.
# How to create a favicon with multiple image sizes and keep alpha transparency
- export your images in the desired sizes (16x16, 32x32 ... max 256x256) as PNGs + alpha
- install ImageMagick
Run this command (replacing the .png files for your own images):
convert favicon-16.png favicon-32.png favicon-64.png -colors 256 -alpha background favicon.ico
The `-alpha background` options is what maintains the alpha channel. You can reduce colors even more if you want, be careful about file size - a favicon with all sizes up to 256px will hit > 100kb.
@cyjake
Copy link
Author

cyjake commented Dec 3, 2013

$ convert favicon-16.png favicon-32.png favicon-64.png \
    -bordercolor transparent -border 0 \
    -colors 256 -alpha background \
    favicon.ico

Add -bordercolor and -border option for anti-aliased result.

@leibnizli
Copy link

This great, although I do not understand

@cyjake
Copy link
Author

cyjake commented Dec 3, 2013

$ convert sapling.png  \
    \( -clone 0 -resize 16x16 \) \
    \( -clone 0 -resize 32x32 \) \
    \( -clone 0 -resize 48x48 \) \
    \( -clone 0 -resize 64x64 \) \
    -alpha background -colors 256 -delete 0 -bordercolor transparent -border 0 \
    favicon.ico

@luckydrq
Copy link

luckydrq commented Dec 3, 2013

this great

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