• Stars
    star
    563
  • Rank 79,150 (Top 2 %)
  • Language
    Java
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Icon management for Mobile Apps. Create icons, generate all required sizes, label and annotate. Supports Native, Cordova, React Native, Xamarin and more. Inspired by cordova-icon.

app-icon

npm version CircleCI AppVeyor Build Status codecov dependencies Status devDependencies Status GuardRails badge Greenkeeper badge Conventional Commits

Icon management for Mobile Apps. Create icons, generate all required sizes, label and annotate. Supports Native, Cordova, React Native, Xamarin and more. Inspired by cordova-icon. Node 10 and onwards supported.

Banner

Introduction

This simple tool allows you to create a single icon in your app project, then create icons of all required sizes from it. It currently works for iOS and Android. You can also add labels to your app icons.

Create a single large icon.png at least 192 pixels square, or run app-icon init to create this icon, then run:

# If you are using npm 5.2 onwards...
npx app-icon generate

# ...for older versions of npm
npm install -g app-icon
app-icon generate

You can also use the module directly in node:

/**
 * appIcon = {
 *   labelImage(inputFilePath, outputFilePath, topText, bottomText),
 *   generate({ sourceIcon, platforms, search }),
 *   templates: {
 *     'AndroidManifest.icons': {...json file...},
 *     'AppIcon.iconset': {...json file...},
 *   },
 * }
 */
import appIcon from 'app-icon';

Promise.resolve()
  .then(() => appIcon.labelImage('./inputfile.png', './out.png', 'UAT', '0.12.3'))
  .then(() => appIcon.labelImage('./inputfile.png', './out.png', 'UAT')) // Bottom text optional
  .then(() => appIcon.labelImage('./inputfile.png', './out.png', null, '0.12.3')) // Top text optional
  .then(() => appIcon.generate()) // will use all default values
  .then(() => appIcon.generate({
    sourceIcon: './icon.png', // Path of the icon to use
    platforms: 'android,ios', // The platforms to generate icons for (i.e. 'android')
    searchRoot: './',
  }));

Installation

Install with:

npm install -g app-icon

You will need imagemagick installed:

brew install imagemagick          # OSX
sudo apt-get install imagemagick  # Debian/Ubuntu/etc
sudo yum install imagemagick      # CentOS/etc

Usage

The app-icon tool can be used to create a simple template icon, generate icons of all sizes from a template icon, or label icons.

Initialising

If you do not already have a single icon to use as the main icon for your project, you can create one with the init command:

app-icon init                    # generates an icon named icon.png

You can also add a simple label to the icon.

app-icon init --caption "App"    # creates an icon with the text 'App'

To create template Adaptive Icons for Android include the --adaptive-icons flag.

Generating Icons

Add an icon (ideally at least 192x192 pixels) named icon.png to your project root (or run app-icon init). To automatically generate icons of all sizes for all app projects in the same folder, run:

app-icon generate

If an iOS project is present, then the icon will be copied at all required sizes to:

./ios/<ProjectName>/Images.xcassets/AppIcon.appiconset

If an Android project is present, then the icon will be copied at all required sizes to:

./android/app/src/main/res

You can limit the platforms which icons are generated for with the --platforms flag, specifying:

app-icon generate --platforms=ios
app-icon generate --platforms=android,ios

By default the tool will generate icons for both platforms.

You can search in specific directories for icons, if the presence of other projects is interfering, just use the --search or -s parameter:

app-icon generate -s ./ios -s ./android

You can specify the path to the source icon, as well as the folder to search for app projects, just run app-icon generate -h to see the options.

Labelling Icons

Add labels to an icon with the command below:

app-icon label -i icon.png -o output.png --top UAT --bottom 0.12.3

This would produce output like the below image:

Labelled Icon Image

This is a useful trick when you are creating things like internal QA versions of your app, where you might want to show a version number or other label in the icon itself.

To label adaptive icons, simply run the label command against the foreground adaptive icon image.

Adaptive Icons

Support for Adaptive Icons for Android is being introduced. This will happen in stages and should be considered an 'alpha' feature until otherwise noted.

The current goals are:

  1. Adaptive Icons are 'opt in' for now, they won't be generated by default
  2. Creating or generating adaptive icons is done via the --adaptive-icons flag

None of the current commands support the --adaptive-icons flag. The init command will be the first to bring support, then generate. If the feature is working well for users then I will document in detail its usage, until then it is an 'experimental' feature!

There is an excellent guide on developing Adaptive Icons here.

To test how adaptive icons will look when animated, swiped, etc, the Adaptive Icons website by Marius Claret is very useful!

Note that Adaptive Icons of all supported sizes are generated. However, we also generate the res/mipmap-anydpi-v26/ adaptive icon. This is a large size icon which Android from v26 onwards will automatically rescale as needed to all other sizes. This technically makes the density specific icons redundant. The reason we generate both is to ensure that after generate is run, all icons in the project will be consistent.

Developer Guide

The only dependencies are Node 10 (or above) and Yarn.

Useful commands for development are:

Command Usage
npm test Runs the unit tests.
npm run test:debug Runs the tests in a debugger. Combine with .only and debugger for ease of debugging.
npm run cov Runs the tests, writing coverage reports to ./artifacts/coverage.

Currently the linting style is based on airbnb. Run npm run lint to lint the code.

Initial Setup

Install the dependencies (I recommend Node Version Manager):

nvm install 8
nvm use 8
git clone [email protected]:dwmkerr/app-icon.git
cd app-icon
npm install && npm test

Running Tests

Run the tests with:

npm test

Tests are executed with Mocha and coverage is handled by Istanbul. Coverage reports are written to an ./artifacts folder.

Note that best practices are to pass Mocha a quoted string with a glob pattern for cross-platform execution of tests (see Mocha Docs). However for some reason on AppVeyor this doesn't seem to work. Leaving the pattern unquoted works for cmd as well as the shell in builds for now. So please be careful if changing the quotes and test on both platforms.

Commit Messages

Conventional Commits should be used. This allows the CHANGELOG to be kept up to date automatically, and ensures that semantic versioning can be expected from the library.

Creating a Release

To create a release.

  • Merge your work to master.
  • Use npm run release.
  • Push and deploy git push --tags && git push && npm publish

Note that semantic-version is used, meaning a changelog is automatically kept up to date, and versioning is handled semantically based on the commit message.

Builds

Builds are run on CircleCI. You can run the CircleCI build locally with the following command:

make circleci

The builds use custom docker images which contain the appropriate Node.js runtime, as well as the ImageMagick binaries. These custom images are stored in the .circleci/images folder. You can use the .circleci/images/makefile makefile to build them, but permissions to push to the dwmkerr Docker Hub account are required to publish these images. In general, these should not need to be modified.

Debugging

The debug package is used to support low-level debugging. If you want to see debug messages when running the tool, just set the DEBUG environment variable to app-icon:

DEBUG=app-icon app-icon generate --platforms android

The Sample Projects

This project includes some sample apps in the test folder, which are used for the tests. You can also run these apps to see the icons produced in action.

React Native

To run:

cd ./test/ReactNativeIconTest/
npm install
react-native run-ios
# OR react-native run-android

Cordova

To run:

cd ./test/CordovaApp/
npm install
cordova run ios
# OR cordova run android

Native

To run the native apps, open the ./test/NativeApp directory, then open the iOS/Android projects in XCode/AndroidStudio as needed.

Compatibility

app-icon dependds on ImageMagick. ImageMagick 6 is installed by default on many Linux distributions, as well as OSX. Some platforms are regularly tested (such as Ubuntu, via CircleCI). Other platforms may work but are not tested when I make a release, so your results may vary.

The table below shows the current confirmed compatibility:

Platform app-icon ImageMagick Status
OSX 0.6.x 6, 7
Ubuntu 14 0.6.x 6

Troubleshooting

Images labelled with app-icon label have the text slightly vertically offset

This seems to be an issue with Imagemagick 6 - try upgrading to 7.

License

MIT

More Repositories

1

hacker-laws

💻📖 Laws, Theories, Principles and Patterns that developers will find useful. #hackerlaws
Shell
25,245
star
2

sharpshell

SharpShell makes it easy to create Windows Shell Extensions using the .NET Framework.
C#
1,478
star
3

sharpgl

Use OpenGL in .NET applications. SharpGL wraps all modern OpenGL features and offers a powerful scene graph to aid development.
C#
720
star
4

consolecontrol

ConsoleControl is a C# class library that lets you embed a console in a WinForms or WPF application.
C#
672
star
5

effective-shell

Text, samples and website for my 'Effective Shell' series.
JavaScript
649
star
6

angular-modal-service

Modal service for AngularJS - supports creating popups and modals via a service.
JavaScript
629
star
7

wait-port

Simple binary to wait for a port to open. Useful for docker-compose and general server side activities.
JavaScript
321
star
8

docker-dynamodb

It's DynamoDB - in Docker!
Shell
230
star
9

spaceinvaders

Classic Space Invaders game written in JavaScript as a learning exercise.
JavaScript
189
star
10

terraform-aws-openshift

Create infrastructure with Terraform and AWS, install OpenShift. Party!
HCL
170
star
11

node-docker-microservice

Demonstrates how to build a testable, deployable, scalable microservice with NodeJS and Docker.
JavaScript
166
star
12

dotfiles

My personal setup. Vim, Tmux, Shells, etc.
Shell
77
star
13

mongo-monitor

CLI to monitor the status of a MongoDB cluster real-time 📈
JavaScript
77
star
14

crosswords-js

Tiny, lightweight crossword control for the web.
JavaScript
57
star
15

terraform-consul-cluster

Demonstrates how to create a resilient Consul cluster on AWS, using Terraform. Companion to my article on dwmkerr.com.
HCL
56
star
16

glmnet

GlmNet is a .NET version of the excellent OpenGL Mathematics library (GLM).
C++
52
star
17

starfield

A nice starfield background using built using HTML and vanilla JavaScript as a learning exercise.
HTML
49
star
18

architecture-as-code

A project to help define architecture logically as code, and generate living, interactive diagrams.
JavaScript
47
star
19

linux-kernel-module

A simple Linux Kernel Module, written as a learning exercise.
C
30
star
20

app-splash

Automatic splash screen generation and resizing for Mobile Apps. Supports Native, React Native, Cordova, Xamarin and more. The little brother of 'app-icon'.
Java
29
star
21

angular-memory-leaks

A small and leaky AngularJS application used to demonstrate how to identify, analyse and resolve memory leaks in JavaScript applications. A companion to the write-up at www.dwmkerr.com/fixing-memory-leaks-in-angularjs-applications
JavaScript
28
star
22

gacmanager

GAC Manager is an open source project that comes in two parts - a fully functional application to manage the Global Assembly Cache on your computer, and a C# API to allow you to manage the GAC yourself.
C#
25
star
23

langtonsant

Langton's Ant implemented in Javascript
JavaScript
23
star
24

sil

Sil is an application and addin for Visual Studio that lets you disassemble your C# code.
C#
21
star
25

file-format-wavefront

A simple .NET library to load data from Wavefront *.obj and *.mlb files.
C#
20
star
26

java-maven-standard-version-sample

This simple module demos how to use Conventional Commits, Git Hooks to enforce Conventional Commits and Semantic Versioning in a Java project built with Maven.
Shell
18
star
27

beautifully-simple-app-ci

This repository demonstrates some beautifully simple techniques for handling CI and CI for mobile apps. These techniques are appliclable to many mobile technologies and development platforms and compliment many different CI/CD toolchains.
Makefile
17
star
28

google-it

Command line tool to quickly look something up on Google!
Go
16
star
29

docker-terraform-ci

A base image for working with Terraform in CI scenarios. Provides Terraform, tflint, AWS CLI, etc.
Dockerfile
14
star
30

learn-a-language

A set of ideas and projects to work on that are great to help you learn a programming language.
14
star
31

dotnet-windows-registry

A simple, unit and integration test friendly wrapper around the Windows Registry, which is 100% compliant with the existing Microsoft.Win32.Registry package.
C#
12
star
32

react-es6-starter

A simple starter template for a React ES6 web app
JavaScript
12
star
33

lex-starter-kit

A starter kit for building chatbots using AWS Lex and Lambda.
Shell
11
star
34

switch

Switch is an Addin for Visual Studio that lets you quickly switch between related files, such as *.cpp and *.h or XAML and code-behind.
C#
9
star
35

svg-smile

Procedurally animated smiley face with SVG and pure JavaScript 😀🙂😐🙁☹️
HTML
8
star
36

node-imagemagick-cli

Access the ImageMagick CLI tools from Node. No dependencies, cross-platform, with support for ImageMagick 6 and 7.
JavaScript
8
star
37

effective-container-engineering

Practical tips and patterns for building good container citizens
JavaScript
7
star
38

terraform-aws-vpc-example

An example terraform module to create an AWS VPC with a cluster of web servers.
HCL
7
star
39

chatgpt-diagrams-extension

A Chrome browser extension that renders diagrams in the ChatGPT website inline.
HTML
7
star
40

lex-chat

A simple CLI for chatting to AWS Lex ChatBots. Great for development!
JavaScript
6
star
41

jsonclient

JsonClient .NET is a lightweight .NET class library that lets you access Json web services
C#
6
star
42

git-speed

Speed up your git flow with these advanced techniques.
Shell
6
star
43

docs

Useful guides, documents, snippets for working with tech.
Shell
5
star
44

firekeys

FireKeys is a Windows Application that lets you assign hotkeys to your favourite programs, URLs or actions.
C#
5
star
45

java-gradle-standard-version-sample

This simple module demos how to use Conventional Commits, Git Hooks to enforce Conventional Commits and Semantic Versioning in a Java project built with Maven.
Java
5
star
46

mongo-connection-string

Handle mongodb connection strings with ease.
JavaScript
4
star
47

makefile-help

A simple snippet that allows you to quickly add a 'help' command to a Makefile to show command documentation.
Shell
4
star
48

better-specs

Great specs can be in markdown.
4
star
49

microservices-playground

☁️🐳 Spin up microservice platforms on the cloud in seconds - use it to evaluate them or try new technologies!
JavaScript
4
star
50

apex

C#
3
star
51

ContentEditableMvc

ContentEditableMvc is a small library for ASP MVC 4 web pages that lets you use the power of the HTML5 contenteditable attribute and Ajax to update content from the client.
C#
3
star
52

docker-shells

A Debian Image will the most popular shells pre-installed. Useful for comparing features between shells.
Makefile
3
star
53

dwmkerr.com

The 'dwmkerr.com' website content and setup. Static site managed with Hugo.
JavaScript
3
star
54

vsix-tools

A set of Powershell functions to help with vsix files.
PowerShell
3
star
55

effective-shell-installer

This is the install script for the https://effective-shell.com samples. This repo hosts the https://effective.sh installer.
Shell
3
star
56

QuickAccent

Windows utility to allow quick selection of accents and symbols to the clipboard.
C#
3
star
57

effective-nodejs-debugging

Presentation, code samples and notes for a talk at JSChannel 2016
HTML
3
star
58

html5base

My personal preferences for a base HTML5 page - includes a css reset and some minor typography tweaks, as well as hyperlink styling.
CSS
2
star
59

terraform-aws-ecs-cluster

Build an Amazon Elastic Container Services Cluster with Terraform.
HCL
2
star
60

dotnet-com-admin

The COM Admin library provides APIs to manage the installation and registration of .NET Framework and .NET Core COM Servers and Shell Extensions
C#
2
star
61

terraform-aws-kubernetes

Create infrastructure with Terraform and AWS, install Kubernetes. Party! http://www.dwmkerr.com/get-up-and-run…
HCL
2
star
62

microservice-zapp

A super simple microservice I often use when demoing docker. Spits out quotes from Zapp Brannigan!
Python
1
star
63

deusnovum

Deus Novum is an HTML5/JS game that lets you take control of a Universe - manipulate time, space and physics to complete challenges.
JavaScript
1
star
64

pythonexperiments

A set of experiments in Python, good for learning.
Python
1
star
65

fsharpexperiments

A general repo for F# projects as learning exercises.
F#
1
star
66

puzlog

Hobby project. Track crossword progress.
HTML
1
star
67

node-configuration

Simple configuration for Node applications, load from files, environment variables or parameters.
1
star
68

template-nodejs-module

A template for a Node.js module that has basic standards for linting, testing, build pipelines, NPM deployment, documentation and contributors.
Shell
1
star
69

seed-node

Starter project for Node.js.
JavaScript
1
star
70

on

A simple tool which helps when working with environment variables, devops and 12 factor apps.
JavaScript
1
star
71

homebrew-tools

A Homebrew Tap for tools which I maintain and publish.
1
star
72

slack-backend

A demo repository showing how Slack can be useful when building backend systems
1
star
73

app-version

Version management for Mobile Apps. Simple tool to set version for Native, React Native, Cordova, Xamarin and more.
JavaScript
1
star