Skip to content

Instantly share code, notes, and snippets.

@arjan
Created May 23, 2014 16:15
Show Gist options
  • Save arjan/1de37bc35da656af0e62 to your computer and use it in GitHub Desktop.
Save arjan/1de37bc35da656af0e62 to your computer and use it in GitHub Desktop.
Quickly create a 9-patch image suitable as splash screen (Android)
#!/bin/bash
FILE="$1"
OUT=$(echo $FILE|sed -e 's/\./.9./')
$(identify -format "export WIDTH=%w" splash.png)
$(identify -format "export HEIGHT=%h" splash.png)
convert $FILE -bordercolor none -border 1 $OUT
mogrify -fill black \
-draw "line 1,0 2,0" \
-draw "line 0,1 0,2" \
-draw "line $(($WIDTH-2)),0 $(($WIDTH-1)),0" \
-draw "line 0,$(($HEIGHT-2)) 0,$(($HEIGHT-1))" \
-draw "line 1,$(($HEIGHT+1)) $(($WIDTH-1)),$(($HEIGHT+1))" \
-draw "line $(($WIDTH+1)),1 $(($WIDTH+1)),$(($HEIGHT-1))" \
$OUT
echo "Written $OUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment