Skip to content

Instantly share code, notes, and snippets.

@neoasis-werx
Forked from mark-ingenosity/svg2icns.sh
Created October 5, 2025 01:22
Show Gist options
  • Save neoasis-werx/6933aa0d2665b6aafd7efb916879d1fb to your computer and use it in GitHub Desktop.
Save neoasis-werx/6933aa0d2665b6aafd7efb916879d1fb to your computer and use it in GitHub Desktop.
[BASH: Image Conversion: SVG to Mac ICNS] #convert #image #file_type #bash #script #icon
#!/bin/bash
# iterate over the svg files fed into on the command line
for svgfile in "$@"
do
name=${f%.*}
ext=${f##*.}
echo "Processing $name ..."
set -e
mkdir $name.iconset
# run inkscape from the command line to generate the iconset formatted for icns
inkscape -z -e "$PWD/$name.iconset/icon_16x16.png" -w 16 -h 16 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/[email protected]" -w 32 -h 32 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/icon_32x32.png" -w 32 -h 32 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/[email protected]" -w 64 -h 64 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/icon_128x128.png" -w 128 -h 128 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/[email protected]" -w 256 -h 256 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/icon_256x256.png" -w 256 -h 256 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/[email protected]" -w 512 -h 512 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/icon_512x512.png" -w 512 -h 512 "$PWD/$svgfile"
inkscape -z -e "$PWD/$name.iconset/[email protected]" -w 1024 -h 1024 "$PWD/$svgfile"
# run osx iconutil app to convert the iconset to icns format
iconutil -c icns "$name.iconset"
#cleanup
rm -R "$name.iconset"
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment