Last active
February 7, 2023 20:04
-
-
Save 2blon9/780db8daa059debe65fbf55aa994fb68 to your computer and use it in GitHub Desktop.
This script can be used for converting png file to icns(MacOS)
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/sh | |
| # Install `imagemagick` first. | |
| # brew install imagemagick | |
| ICONSETNAME=$1 | |
| mkdir $ICONSETNAME.iconset | |
| cp $ICONSETNAME.png $ICONSETNAME.iconset/ | |
| cd $ICONSETNAME.iconset | |
| convert -resize 16x16 ../$ICONSETNAME.png icon_16x16.png | |
| convert -resize 32x32 ../$ICONSETNAME.png icon_16x16@2x.png | |
| convert -resize 32x32 ../$ICONSETNAME.png icon_32x32.png | |
| convert -resize 64x64 ../$ICONSETNAME.png icon_32x32@2x.png | |
| convert -resize 128x128 ../$ICONSETNAME.png icon_128x128.png | |
| convert -resize 256x256 ../$ICONSETNAME.png icon_128x128@2x.png | |
| convert -resize 256x256 ../$ICONSETNAME.png icon_256x256.png | |
| convert -resize 512x512 ../$ICONSETNAME.png icon_256x256@2x.png | |
| convert -resize 512x512 ../$ICONSETNAME.png icon_512x512.png | |
| convert -resize 1024x1024 ../$ICONSETNAME.png icon_512x512@2x.png | |
| cd .. | |
| iconutil -c icns $ICONSETNAME.iconset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#!/bin/sh
Install
imagemagickfirst.brew install imagemagick
ICONSETNAME_=$1
ICONSETNAME=${ICONSETNAME_%%.*}
mkdir $ICONSETNAME.iconset
cp $ICONSETNAME.png $ICONSETNAME.iconset/
cd $ICONSETNAME.iconset
sips -z 16 16 ../$ICONSETNAME.png --out icon_16x16.png
sips -z 32 32 ../$ICONSETNAME.png --out icon_16x16@2x.png
sips -z 32 32 ../$ICONSETNAME.png --out icon_32x32.png
sips -z 64 64 ../$ICONSETNAME.png --out icon_32x32@2x.png
sips -z 128 128 ../$ICONSETNAME.png --out icon_128x128.png
sips -z 256 256 ../$ICONSETNAME.png --out icon_128x128@2x.png
sips -z 256 256 ../$ICONSETNAME.png --out icon_256x256.png
sips -z 512 512 ../$ICONSETNAME.png --out icon_256x256@2x.png
sips -z 512 512 ../$ICONSETNAME.png --out icon_512x512.png
sips -z 1024 1024 ../$ICONSETNAME.png --out icon_512x512@2x.png
cd ..
iconutil -c icns $ICONSETNAME.iconset