Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Created by .ignore support plugin (hsz.mobi)
.idea
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DESCRIPTION:
dstpath - The destination path where the icons generate to.

This script is depend on ImageMagick. So you must install ImageMagick first
You can use 'sudo brew install ImageMagick' to install it
Please see http://www.imagemagick.org/script/binary-releases.php for installation instructions

AUTHOR:
Pawpaw<lvyexuwenfa100@126.com>
Expand All @@ -42,7 +42,7 @@ EXAMPLE:
chmod 777 ios-icon-generator.sh
</pre>
3. Run
<pre>
<pre>
StarnetdeMacBook-Pro:ios-icon-generator starnet$ ./ios-icon-generator.sh ~/Downloads/1024.png ~/output
[INFO] Generate iTunesArtwork.png ...
[INFO] Generate iTunesArtwork@2x.png ...
Expand All @@ -63,7 +63,8 @@ StarnetdeMacBook-Pro:ios-icon-generator starnet$ ./ios-icon-generator.sh ~/Downl
[INFO] Generate Icon-72@2x.png ...
[INFO] Generate Icon-Small-50.png ...
[INFO] Generate Icon-Small-50@2x.png ...
[INFO] Generate Done.</pre>
[INFO] Generate Done.
</pre>
PS: You can find out the icons in ~/output directory.

### Navigation bar items
Expand All @@ -72,7 +73,17 @@ There is also another shell script `ios-navbar-icon-generator.sh` to generate na
### Generic images
With the script `os-custom-icon-generator.sh` you can generate a set of three images to use in your app (myimg.png, myimg@2.png, myimg@3.png).
Use it in this way `./ios-custom-icon-generator.sh icon-big.png ~/asset_dir 100`. The third parameter is the final base size of the image: using 100, your output image.png will be 100x100 px, image@2.png 200x200 and image@3.png 300x300.
`

### Supported source formats

* JPG
* PNG
* SVG (with custom settings: -background none -density 1200 )
* TIFF
* etc

see full list running `identify -list format`. Please note: some formats may require additional parameters


### Refer
* [App Icons on iPad and iPhone](https://developer.apple.com/library/ios/qa/qa1686/_index.html)
Expand Down
53 changes: 38 additions & 15 deletions ios-custom-icon-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ set -e

SRC_FILE="$1"
DST_PATH="$2"
SIZE="$3"
SIZE_WIDTH="$3"
SIZE_HEIGHT="$4"

VERSION=1.0.0
VERSION=1.1.0

info() {
local green="\033[1;32m"
Expand Down Expand Up @@ -57,24 +58,39 @@ DESCRIPTION:
size - The destination size in pixel, only one number (e.g 60)

This script is depend on ImageMagick. So you must install ImageMagick first
You can use 'sudo brew install ImageMagick' to install it
Please see http://www.imagemagick.org/script/binary-releases.php for installation instructions

AUTHOR:
Alessandro Miliucci<lifeisfoo@gmail.com>
Vladimir Bilyov<vladimir.bilyov@gmail.com>

LICENSE:
This script follow MIT license.

EXAMPLE:
$0 icon-big.png ~/asset_dir 100
$0 icon-big.png ~/asset_dir 100 50
EOF
}

# Check ImageMagick
command -v convert >/dev/null 2>&1 || { error >&2 "The ImageMagick is not installed. Please use brew to install it first."; exit -1; }
SVG_SETTINGS="-background none -density 1200"

function _convert(){
SRCFILE=$1
FILEEXT=${SRCFILE##*.}
SIZE=$2
DSTFILE=$3

info "Generate $DSTFILE ..."
if [ $FILEEXT = "svg" ]; then
convert $SVG_SETTINGS -resize $SIZE $SRCFILE $DSTFILE
else
convert $SRCFILE -resize $SIZE $DSTFILE
fi
}


# Check param
if [ $# != 3 ];then
if [ $# != 4 ];then
usage
exit -1
fi
Expand All @@ -91,13 +107,20 @@ FILENAME=$(basename "$SRC_FILE")
FILENAME="${FILENAME%.*}"
OUT_FILENAME="$FILENAME.png"

info "Generate $FILENAME.png ..."
convert "$SRC_FILE" -resize "$SIZE"x"$SIZE" "$DST_PATH/$FILENAME.png"
info "Generate $FILENAME@2x.png ..."
DOUBLE_SIZE=$(($SIZE * 2))
convert "$SRC_FILE" -resize "$DOUBLE_SIZE"x"$DOUBLE_SIZE" "$DST_PATH/$FILENAME@2x.png"
TRIPLE_SIZE=$(($SIZE * 3))
info "Generate $FILENAME@3x.png ..."
convert "$SRC_FILE" -resize "$TRIPLE_SIZE"x"$TRIPLE_SIZE" "$DST_PATH/$FILENAME@3x.png"
#info "Generate $FILENAME.png ..."
#convert "$SRC_FILE" -resize "$SIZE_WIDTH"x"$SIZE_HEIGHT" "$DST_PATH/$FILENAME.png"
_convert "$SRC_FILE" "$SIZE_WIDTH"x"$SIZE_HEIGHT" "$DST_PATH/$FILENAME.png"

#info "Generate $FILENAME@2x.png ..."
DOUBLE_WIDTH=$(($SIZE_WIDTH * 2))
DOUBLE_HEIGHT=$(($SIZE_HEIGHT * 2))
#convert "$SRC_FILE" -resize "$DOUBLE_SIZE"x"$DOUBLE_HEIGHT" "$DST_PATH/$FILENAME@2x.png"
_convert "$SRC_FILE" "$DOUBLE_WIDTH"x"$DOUBLE_HEIGHT" "$DST_PATH/$FILENAME@2x.png"

TRIPLE_WIDTH=$(($SIZE_WIDTH * 3))
TRIPLE_HEIGHT=$(($SIZE_HEIGHT * 3))
#info "Generate $FILENAME@3x.png ..."
#convert "$SRC_FILE" -resize "$TRIPLE_SIZE"x"$TRIPLE_HEIGHT" "$DST_PATH/$FILENAME@3x.png"
_convert "$SRC_FILE" "$TRIPLE_WIDTH"x"$TRIPLE_HEIGHT" "$DST_PATH/$FILENAME@3x.png"

info 'Generate Done.'
99 changes: 49 additions & 50 deletions ios-icon-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,41 @@ set -e
SRC_FILE="$1"
DST_PATH="$2"

AI_SETTINGS="-antialias -background transparent -density 600"

VERSION=1.0.0

SIZES=(
"512x512:iTunesArtwork.png"
"1024x1024:iTunesArtwork@2x.png"

"29x29:Icon-29.png"
"58x58:Icon-29@2x.png"
"87x87:Icon-29@3x.png"

"40x40:Icon-40.png"
"80x80:Icon-40@2x.png"
"120x120:Icon-40@3x.png"

"60x60:Icon-60.png"
"120x120:Icon-60@2x.png"
"180x180:Icon-60@3x.png"

"76x76:Icon-76.png"
"152x152:Icon-76@2x.png"

"167x167:Icon-83.5@2x.png"

"57x57:Icon-57.png"
"114x114:Icon-57@2x.png"

"72x72:Icon-72.png"
"144x144:Icon-72@2x.png"

"50x50:Icon-50.png"
"100x100:Icon-50@2x.png"
)

info() {
local green="\033[1;32m"
local normal="\033[0m"
Expand All @@ -52,16 +85,17 @@ DESCRIPTION:
dstpath - The destination path where the icons generate to.

This script is depend on ImageMagick. So you must install ImageMagick first
You can use 'sudo brew install ImageMagick' to install it
Please see http://www.imagemagick.org/script/binary-releases.php for installation instructions

AUTHOR:
Pawpaw<lvyexuwenfa100@126.com>
Vladimir<vladimir.bilyov@gmail.com>

LICENSE:
This script follow MIT license.

EXAMPLE:
$0 1024.png ~/123
$0 1024.ai ~/123
EOF
}

Expand All @@ -81,53 +115,18 @@ fi

# Generate, refer to:https://developer.apple.com/library/ios/qa/qa1686/_index.html

info 'Generate iTunesArtwork.png ...'
convert "$SRC_FILE" -resize 512x512 "$DST_PATH/iTunesArtwork.png"
info 'Generate iTunesArtwork@2x.png ...'
convert "$SRC_FILE" -resize 1024x1024 "$DST_PATH/iTunesArtwork@2x.png"

info 'Generate Icon-Small.png ...'
convert "$SRC_FILE" -resize 29x29 "$DST_PATH/Icon-Small.png"
info 'Generate Icon-Small@2x.png ...'
convert "$SRC_FILE" -resize 58x58 "$DST_PATH/Icon-Small@2x.png"
info 'Generate Icon-Small@3x.png ...'
convert "$SRC_FILE" -resize 87x87 "$DST_PATH/Icon-Small@3x.png"

info 'Generate Icon-Small-40.png ...'
convert "$SRC_FILE" -resize 40x40 "$DST_PATH/Icon-Small-40.png"
info 'Generate Icon-Small-40@2x.png ...'
convert "$SRC_FILE" -resize 80x80 "$DST_PATH/Icon-Small-40@2x.png"
info 'Generate Icon-Small-40@3x.png ...'
convert "$SRC_FILE" -resize 120x120 "$DST_PATH/Icon-Small-40@3x.png"

info 'Generate Icon-60.png ...'
convert "$SRC_FILE" -resize 60x60 "$DST_PATH/Icon-60.png"
info 'Generate Icon-60@2x.png ...'
convert "$SRC_FILE" -resize 120x120 "$DST_PATH/Icon-60@2x.png"
info 'Generate Icon-60@3x.png ...'
convert "$SRC_FILE" -resize 180x180 "$DST_PATH/Icon-60@3x.png"

info 'Generate Icon-76.png ...'
convert "$SRC_FILE" -resize 76x76 "$DST_PATH/Icon-76.png"
info 'Generate Icon-76@2x.png ...'
convert "$SRC_FILE" -resize 152x152 "$DST_PATH/Icon-76@2x.png"

info 'Generate Icon-83.5@2x.png ...'
convert "$SRC_FILE" -resize 167x167 "$DST_PATH/Icon-83.5@2x.png"

info 'Generate Icon.png ...'
convert "$SRC_FILE" -resize 57x57 "$DST_PATH/Icon.png"
info 'Generate Icon@2x.png ...'
convert "$SRC_FILE" -resize 114x114 "$DST_PATH/Icon@2x.png"

info 'Generate Icon-72.png ...'
convert "$SRC_FILE" -resize 72x72 "$DST_PATH/Icon-72.png"
info 'Generate Icon-72@2x.png ...'
convert "$SRC_FILE" -resize 144x144 "$DST_PATH/Icon-72@2x.png"

info 'Generate Icon-Small-50.png ...'
convert "$SRC_FILE" -resize 50x50 "$DST_PATH/Icon-Small-50.png"
info 'Generate Icon-Small-50@2x.png ...'
convert "$SRC_FILE" -resize 100x100 "$DST_PATH/Icon-Small-50@2x.png"
ext=${SRC_FILE##*.}

for size in "${SIZES[@]}" ; do
ICON_SIZE=${size%%:*}
ICON_FILE=${size#*:}

info "Generate $ICON_FILE ..."
if [ "$ext" = "ai" ]; then
convert $AI_SETTINGS -resize $ICON_SIZE "$SRC_FILE" "$DST_PATH/$ICON_FILE"
else
convert "$SRC_FILE" -resize $ICON_SIZE "$DST_PATH/$ICON_FILE"
fi
done

info 'Generate Done.'
2 changes: 1 addition & 1 deletion ios-navbar-icon-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DESCRIPTION:
dstpath - The destination path where the icons generate to.

This script is depend on ImageMagick. So you must install ImageMagick first
You can use 'sudo brew install ImageMagick' to install it
Please see http://www.imagemagick.org/script/binary-releases.php for installation instructions

AUTHOR:
Alessandro Miliucci<lifeisfoo@gmail.com>
Expand Down