Skip to content

Instantly share code, notes, and snippets.

@kirpachov
Created March 15, 2022 09:06
Show Gist options
  • Select an option

  • Save kirpachov/d805c26b05393bb942071e935653c31f to your computer and use it in GitHub Desktop.

Select an option

Save kirpachov/d805c26b05393bb942071e935653c31f to your computer and use it in GitHub Desktop.

Svg to ico with ubuntu bash

1. Install

NOTE: Some of this may be unecessary, idk sudo apt install inkscape imagemagick libcanberra-gtk-module libcanberra-gtk3-module canberra-gtk-module

2. Insert into ~/.bashrc

# This function will generate a '.ico' from a '.svg' and it will mov to the requested path
# e.g ==> svgtoico logo7 logo7.svg src/favicon.ico
svgtoico(){
        inkscape -w 16 -h 16 -e "$1-16.png" "$2" &&
        inkscape -w 32 -h 32 -e "$1-32.png" "$2" &&
        inkscape -w 48 -h 48 -e "$1-48.png" "$2" &&
        convert "$1-16.png" "$1-32.png" "$1-48.png" "$1.ico" &&
        rm "$1-16.png" && rm "$1-32.png" && rm "$1-48.png" &&
        mv "$1.ico" "$3"
}

3. Convert!

svgtoico logo7 logo7.svg src/favicon.ico svgtoico (logoname) (svgname) (location_of_new_icon)

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