Skip to content

Instantly share code, notes, and snippets.

@sehugg
Created October 25, 2014 12:44
Show Gist options
  • Save sehugg/5ac2d1d261c529e881bd to your computer and use it in GitHub Desktop.
Save sehugg/5ac2d1d261c529e881bd to your computer and use it in GitHub Desktop.
##
## Android/iOS icon and default image resizer
## Requirements: apt-get install imagemagick pngquant
##
## 512x512 square Android icon
SRCICON=art/icon-512.png
## 512x512 icon for iOS
IOSICON=art/icon-ios-512.png
## Default screen for iOS
## (should be 1536x2048 or 2048x1536 for landscale)
WELCOME=art/welcome.png
PNGCRUSH=pngquant -
PNGCRUSH2=pngquant --nofs -
TARGETS=\
android/ic_launcher-web.png \
android/res/drawable-mdpi/ic_launcher.png android/res/drawable-xhdpi/ic_launcher.png android/res/drawable-xxhdpi/ic_launcher.png android/res/drawable-hdpi/ic_launcher.png android/res/drawable-xxxhdpi/ic_launcher.png \
ios/data/Icon.png ios/data/Icon@2x.png ios/data/Icon-72.png ios/data/Icon-72@2x.png \
ios/data/Icon-60.png ios/data/Icon-60@2x.png ios/data/Icon-76.png ios/data/Icon-76@2x.png \
ios/data/Default-568h@2x.png ios/data/Default.png ios/data/Default@2x.png ios/data/Default@2x~ipad.png ios/data/Default~ipad.png
all: $(TARGETS)
clean:
rm -f $(TARGETS)
##
## Android icons
##
android/ic_launcher-web.png: $(SRCICON)
convert $< -resize 512x512 - | $(PNGCRUSH) > $@
android/res/drawable-mdpi/ic_launcher.png: $(SRCICON)
convert $< -resize 48x48 - | $(PNGCRUSH) > $@
android/res/drawable-hdpi/ic_launcher.png: $(SRCICON)
convert $< -resize 72x72 - | $(PNGCRUSH) > $@
android/res/drawable-xhdpi/ic_launcher.png: $(SRCICON)
convert $< -resize 96x96 - | $(PNGCRUSH) > $@
android/res/drawable-xxhdpi/ic_launcher.png: $(SRCICON)
convert $< -resize 144x144 - | $(PNGCRUSH) > $@
android/res/drawable-xxxhdpi/ic_launcher.png: $(SRCICON)
convert $< -resize 192x192 - | $(PNGCRUSH) > $@
##
## iOS icons
##
ios/data/Icon.png: $(IOSICON)
convert $< -resize 57x57 - | $(PNGCRUSH) > $@
ios/data/Icon@2x.png: $(IOSICON)
convert $< -resize 114x114 - | $(PNGCRUSH) > $@
ios/data/Icon-60.png: $(IOSICON)
convert $< -resize 60x60 - | $(PNGCRUSH) > $@
ios/data/Icon-60@2x.png: $(IOSICON)
convert $< -resize 120x120 - | $(PNGCRUSH) > $@
ios/data/Icon-72.png: $(IOSICON)
convert $< -resize 72x72 - | $(PNGCRUSH) > $@
ios/data/Icon-72@2x.png: $(IOSICON)
convert $< -resize 144x144 - | $(PNGCRUSH) > $@
ios/data/Icon-76.png: $(IOSICON)
convert $< -resize 76x76 - | $(PNGCRUSH) > $@
ios/data/Icon-76@2x.png: $(IOSICON)
convert $< -resize 152x152 - | $(PNGCRUSH) > $@
##
## iOS Default images
## NOTE: These are for portrait mode, swap the width and height for landscape
##
ios/data/Default-568h@2x.png: $(WELCOME)
convert $< -resize "640x1136^" -gravity center -crop 640x1136+0+0 - | $(PNGCRUSH2) > $@
ios/data/Default.png: $(WELCOME)
convert $< -resize "320x480^" -gravity center -crop 320x480+0+0 - | $(PNGCRUSH2) > $@
ios/data/Default@2x.png: $(WELCOME)
convert $< -resize "640x960^" -gravity center -crop 640x960+0+0 - | $(PNGCRUSH2) > $@
ios/data/Default@2x~ipad.png: $(WELCOME)
convert $< -resize "1536x2048^" -gravity center -crop 1536x2048+0+0 - | $(PNGCRUSH2) > $@
ios/data/Default~ipad.png: $(WELCOME)
convert $< -resize "768x1024^" -gravity center -crop 768x1024+0+0 - | $(PNGCRUSH2) > $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment