Last active
March 31, 2026 12:15
-
-
Save mark-ingenosity/6b9a29123e3df925e56029917cfb3f3a to your computer and use it in GitHub Desktop.
[BASH: Image Conversion: SVG to Mac ICNS] #convert #image #file_type #bash #script #icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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/icon_16x16@2x.png" -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/icon_32x32@2x.png" -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/icon_128x128@2x.png" -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/icon_256x256@2x.png" -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/icon_512x512@2x.png" -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
Thank you for your script!
I had to change it a little to get it to work on macOS Tahoe 26.1 / GNU Bash 3.2.57