Skip to content

Instantly share code, notes, and snippets.

@roblabs
Forked from benvium/generateAppIcon.sh
Last active May 28, 2022 12:11
Show Gist options
  • Select an option

  • Save roblabs/527458cbe46b0483cd2d594c7b9e583f to your computer and use it in GitHub Desktop.

Select an option

Save roblabs/527458cbe46b0483cd2d594c7b9e583f to your computer and use it in GitHub Desktop.

Revisions

  1. roblabs revised this gist Oct 6, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions generateAppIcon.sh
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,8 @@
    # Updated in October 2017 for RobLabs.com
    # https://gist.github.com/roblabs/527458cbe46b0483cd2d594c7b9e583f
    # Based on Xcode Version 9.0 (9A235)
    # requires imagemagick
    # `brew install imagemagick`

    sourceIconName=$1

  2. roblabs revised this gist Oct 6, 2017. 1 changed file with 146 additions and 80 deletions.
    226 changes: 146 additions & 80 deletions generateAppIcon.sh
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,18 @@

    # --------------------------------------------------------
    # Generate app icons and xcassets file from a single image
    # Ben Clayton, Calvium Ltd.
    # Ben Clayton, Calvium Ltd.
    # https://gist.github.com/benvium/2be6d673aa9ac284bb8a
    # --------------------------------------------------------
    # To use this, place script in `appname` folder inside your project (i.e. the folder that Xcode generates for you containing your source code, it's named after whatever you called the app).
    # Create folder there called `RawImages`.
    # Source icon should 1024x1024 and be called appIcon.png. If the icon changes, you can just run this again to regenerate everything.
    # This script assumes that you have the default setup of an Images.xcassets file containing the AppIcon.appiconset.
    # Adjust iconPath below if you use something different
    sourceIconName="RawImages/appIcon.png"
    #
    # Usage with an input of 1024x1024 PNG file
    # generateAppIcon.sh AppIcon.png
    #
    # Updated in October 2017 for RobLabs.com
    # https://gist.github.com/roblabs/527458cbe46b0483cd2d594c7b9e583f
    # Based on Xcode Version 9.0 (9A235)

    sourceIconName=$1

    # Ensure we're running in location of script.
    #cd "`dirname $0`"
    @@ -18,113 +22,175 @@ sourceIconName="RawImages/appIcon.png"
    # http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
    command -v convert >/dev/null 2>&1 || { echo >&2 "I require imagemagick but it's not installed. Aborting."; exit 1; }

    iconPath="Images.xcassets/AppIcon.appiconset"
    iconPath="./Assets.xcassets/AppIcon.appiconset"

    mkdir -p "$iconPath"

    # clean it out
    rm -rf $iconPath/*.png

    # iPhone and iPad iOS7+ Sizes
    convert $sourceIconName -resize 120x120 $iconPath/[email protected]
    convert $sourceIconName -resize 180x180 $iconPath/[email protected]
    convert $sourceIconName -resize 76x76 $iconPath/appicon-76.png
    convert $sourceIconName -resize 152x152 $iconPath/[email protected]
    convert $sourceIconName -resize 40x40 $iconPath/appicon-Small-40.png
    convert $sourceIconName -resize 80x80 $iconPath/[email protected]
    convert $sourceIconName -resize 120x120 $iconPath/[email protected]
    convert $sourceIconName -resize 29x29 $iconPath/appicon-Small.png
    convert $sourceIconName -resize 58x58 $iconPath/[email protected]
    convert $sourceIconName -resize 87x87 $iconPath/[email protected]
    # iPhone Notification
    convert $sourceIconName -resize 40x40 $iconPath/[email protected]
    convert $sourceIconName -resize 60x60 $iconPath/[email protected]

    # iPhone Spotlight Settings
    convert $sourceIconName -resize 29x29 $iconPath/iPhone-Spotlight-Settings-29pt.png
    convert $sourceIconName -resize 58x58 $iconPath/[email protected]
    convert $sourceIconName -resize 87x87 $iconPath/[email protected]

    # iPhone Spotlight
    convert $sourceIconName -resize 80x80 $iconPath/[email protected]
    convert $sourceIconName -resize 120x120 $iconPath/[email protected]

    # iPhone App
    convert $sourceIconName -resize 120x120 $iconPath/[email protected]
    convert $sourceIconName -resize 180x180 $iconPath/[email protected]

    # iPad Notifications
    convert $sourceIconName -resize 20x20 $iconPath/iPad-Notifications-20pt.png
    convert $sourceIconName -resize 40x40 $iconPath/[email protected]

    # iPad Settings
    convert $sourceIconName -resize 29x29 $iconPath/iPad-Settings-29pt.png
    convert $sourceIconName -resize 58x58 $iconPath/[email protected]

    # iPad Spotlight
    convert $sourceIconName -resize 40x40 $iconPath/iPad-Spotlight-40pt.png
    convert $sourceIconName -resize 80x80 $iconPath/[email protected]

    # iPad App
    convert $sourceIconName -resize 76x76 $iconPath/iPad-App-76pt.png
    convert $sourceIconName -resize 152x152 $iconPath/[email protected]

    # iPad Pro App
    convert $sourceIconName -resize 167x167 $iconPath/[email protected]

    # iOS Marketing
    convert $sourceIconName -resize 1024x1024 $iconPath/[email protected]



    cat > "$iconPath/Contents.json" << EOF
    {
    "images" : [
    "images": [
    {
    "size": "20x20",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "size": "20x20",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "3x"
    },
    {
    "size": "29x29",
    "idiom": "iphone",
    "filename": "iPhone-Spotlight-Settings-29pt.png",
    "scale": "1x"
    },
    {
    "size": "29x29",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "size": "29x29",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "3x"
    },
    {
    "size": "40x40",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "iphone",
    "scale" : "2x",
    "size" : "60x60"
    ,"filename" : "[email protected]"
    "size": "40x40",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "3x"
    },
    {
    "idiom" : "iphone",
    "scale" : "3x",
    "size" : "60x60"
    ,"filename" : "[email protected]"
    "size": "60x60",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "ipad",
    "scale" : "1x",
    "size" : "76x76"
    ,"filename" : "appicon-76.png"
    "size": "60x60",
    "idiom": "iphone",
    "filename": "[email protected]",
    "scale": "3x"
    },
    {
    "idiom" : "ipad",
    "scale" : "2x",
    "size" : "76x76"
    ,"filename" : "[email protected]"
    "size": "20x20",
    "idiom": "ipad",
    "filename": "iPad-Notifications-20pt.png",
    "scale": "1x"
    },
    {
    "idiom" : "iphone",
    "scale" : "1x",
    "size" : "29x29"
    ,"filename" : "appicon-Small.png"
    "size": "20x20",
    "idiom": "ipad",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "iphone",
    "scale" : "2x",
    "size" : "29x29"
    ,"filename" : "[email protected]"
    "size": "29x29",
    "idiom": "ipad",
    "filename": "iPad-Settings-29pt.png",
    "scale": "1x"
    },
    {
    "idiom" : "iphone",
    "scale" : "3x",
    "size" : "29x29"
    ,"filename" : "[email protected]"
    "size": "29x29",
    "idiom": "ipad",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "iphone",
    "scale" : "2x",
    "size" : "40x40"
    ,"filename" : "[email protected]"
    "size": "40x40",
    "idiom": "ipad",
    "filename": "iPad-Spotlight-40pt.png",
    "scale": "1x"
    },
    {
    "idiom" : "iphone",
    "scale" : "3x",
    "size" : "40x40"
    ,"filename" : "[email protected]"
    "size": "40x40",
    "idiom": "ipad",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "ipad",
    "scale" : "1x",
    "size" : "40x40"
    ,"filename" : "appicon-Small-40.png"
    "size": "76x76",
    "idiom": "ipad",
    "filename": "iPad-App-76pt.png",
    "scale": "1x"
    },
    {
    "idiom" : "ipad",
    "scale" : "2x",
    "size" : "40x40"
    ,"filename" : "[email protected]"
    "size": "76x76",
    "idiom": "ipad",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "ipad",
    "scale" : "1x",
    "size" : "29x29"
    ,"filename" : "appicon-Small.png"
    "size": "83.5x83.5",
    "idiom": "ipad",
    "filename": "[email protected]",
    "scale": "2x"
    },
    {
    "idiom" : "ipad",
    "scale" : "2x",
    "size" : "29x29"
    ,"filename" : "[email protected]"
    "size": "1024x1024",
    "idiom": "ios-marketing",
    "filename": "[email protected]",
    "scale": "1x"
    }
    ],
    "info" : {
    "version" : 1,
    "author" : "xcode"
    "info": {
    "version": 1,
    "author": "xcode"
    },
    "properties" : {
    "pre-rendered" : true
    "properties": {
    "pre-rendered": true
    }
    }
    EOF
  3. @benvium benvium revised this gist Dec 10, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion generateAppIcon.sh
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,8 @@ command -v convert >/dev/null 2>&1 || { echo >&2 "I require imagemagick but it's

    iconPath="Images.xcassets/AppIcon.appiconset"

    mkdir -p "$iconPath"

    # clean it out
    rm -rf $iconPath/*.png

    @@ -125,4 +127,4 @@ cat > "$iconPath/Contents.json" << EOF
    "pre-rendered" : true
    }
    }
    EOF
    EOF
  4. @benvium benvium revised this gist Sep 22, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion generateAppIcon.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    #!/bin/bash -e

    # Generate app icons and xcassets file from a single image.
    # --------------------------------------------------------
    # Generate app icons and xcassets file from a single image
    # Ben Clayton, Calvium Ltd.
    # --------------------------------------------------------
    # To use this, place script in `appname` folder inside your project (i.e. the folder that Xcode generates for you containing your source code, it's named after whatever you called the app).
    # Create folder there called `RawImages`.
  5. @benvium benvium revised this gist Sep 22, 2015. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions generateAppIcon.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,12 @@
    #!/bin/bash -e

    # Generate app icons and xcassets file from a single image.
    # --------------------------------------------------------
    # To use this, place script in `appname` folder inside your project (i.e. the folder that Xcode generates for you containing your source code, it's named after whatever you called the app).
    # Create folder there called `RawImages`.
    # Source icon should 1024x1024 and be called appIcon.png. If the icon changes, you can just run this again to regenerate everything.
    # This script assumes that you have the default setup of an Images.xcassets file containing the AppIcon.appiconset.
    # Adjust iconPath below if you use something different
    sourceIconName="RawImages/appIcon.png"

    # Ensure we're running in location of script.
  6. @benvium benvium revised this gist Sep 22, 2015. No changes.
  7. @benvium benvium revised this gist Sep 22, 2015. No changes.
  8. @benvium benvium created this gist Sep 22, 2015.
    119 changes: 119 additions & 0 deletions generateAppIcon.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,119 @@
    #!/bin/bash -e

    sourceIconName="RawImages/appIcon.png"

    # Ensure we're running in location of script.
    #cd "`dirname $0`"

    # Check imagemagick is installed
    # http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
    command -v convert >/dev/null 2>&1 || { echo >&2 "I require imagemagick but it's not installed. Aborting."; exit 1; }

    iconPath="Images.xcassets/AppIcon.appiconset"

    # clean it out
    rm -rf $iconPath/*.png

    # iPhone and iPad iOS7+ Sizes
    convert $sourceIconName -resize 120x120 $iconPath/[email protected]
    convert $sourceIconName -resize 180x180 $iconPath/[email protected]
    convert $sourceIconName -resize 76x76 $iconPath/appicon-76.png
    convert $sourceIconName -resize 152x152 $iconPath/[email protected]
    convert $sourceIconName -resize 40x40 $iconPath/appicon-Small-40.png
    convert $sourceIconName -resize 80x80 $iconPath/[email protected]
    convert $sourceIconName -resize 120x120 $iconPath/[email protected]
    convert $sourceIconName -resize 29x29 $iconPath/appicon-Small.png
    convert $sourceIconName -resize 58x58 $iconPath/[email protected]
    convert $sourceIconName -resize 87x87 $iconPath/[email protected]

    cat > "$iconPath/Contents.json" << EOF
    {
    "images" : [
    {
    "idiom" : "iphone",
    "scale" : "2x",
    "size" : "60x60"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "iphone",
    "scale" : "3x",
    "size" : "60x60"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "ipad",
    "scale" : "1x",
    "size" : "76x76"
    ,"filename" : "appicon-76.png"
    },
    {
    "idiom" : "ipad",
    "scale" : "2x",
    "size" : "76x76"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "iphone",
    "scale" : "1x",
    "size" : "29x29"
    ,"filename" : "appicon-Small.png"
    },
    {
    "idiom" : "iphone",
    "scale" : "2x",
    "size" : "29x29"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "iphone",
    "scale" : "3x",
    "size" : "29x29"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "iphone",
    "scale" : "2x",
    "size" : "40x40"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "iphone",
    "scale" : "3x",
    "size" : "40x40"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "ipad",
    "scale" : "1x",
    "size" : "40x40"
    ,"filename" : "appicon-Small-40.png"
    },
    {
    "idiom" : "ipad",
    "scale" : "2x",
    "size" : "40x40"
    ,"filename" : "[email protected]"
    },
    {
    "idiom" : "ipad",
    "scale" : "1x",
    "size" : "29x29"
    ,"filename" : "appicon-Small.png"
    },
    {
    "idiom" : "ipad",
    "scale" : "2x",
    "size" : "29x29"
    ,"filename" : "[email protected]"
    }
    ],
    "info" : {
    "version" : 1,
    "author" : "xcode"
    },
    "properties" : {
    "pre-rendered" : true
    }
    }
    EOF