Skip to content

Instantly share code, notes, and snippets.

@evanpurkhiser
Created December 1, 2012 11:47
Show Gist options
  • Save evanpurkhiser/4181758 to your computer and use it in GitHub Desktop.
Save evanpurkhiser/4181758 to your computer and use it in GitHub Desktop.
Creates ICOs from the Faenza icon package
#!/bin/bash
# [!! WARNING]
# This script will remove some icons from the original set.
# It's probably best if you make a copy of the original
# USAGE:
# Run this script from the within the Faenza icon directory that contains
# each different category of icon (apps, categories, places, etc...)
# Depends on the ImageMagick convert tool
convert_icons()
{
mkdir -p 128
mkdir -p 256
find 96/ -name "*.png" -type f -print0 | while read -d $'\0' icon
do
name="$(basename ${icon} .png)"
# 128x128
convert -background none -density 96 "scalable/${name}.svg" "128/${name}.png"
# 256x256
convert -background none -density 192 "scalable/${name}.svg" "256/${name}.png"
done
mkdir -p ico
list="$(find {16,22,24,32,48,64,96,128,256}/*.png -type f -exec basename {} \; | sort | uniq)"
for icon in ${list}
do
# Error messages are redirected to null since it's possible that the
# icon doesn't exist in all of the size directories
convert -quiet "./16/${icon}" "./22/${icon}" "./24/${icon}" "./32/${icon}" "./48/${icon}" "./64/${icon}" "./96/${icon}" "./128/${icon}" "./256/${icon}" "./ico/${icon%.*}.ico" 2> /dev/null
done
}
# Remove duplicate icons
echo "Removing duplicate icons (symlinks)"
find . -type l -exec rm {} \;
echo
# Convert icon sets
for folder in actions apps categories devices emblems mimetypes places status stock
do
cd ${folder}
echo -e " \e[00;32m=>\e[00m Converting ${folder} to .ico files"
convert_icons;
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment