Giter Site home page Giter Site logo

dwmkerr / app-icon Goto Github PK

View Code? Open in Web Editor NEW
562.0 11.0 56.0 39.52 MB

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.

License: MIT License

JavaScript 15.60% Java 52.92% Objective-C 24.57% Makefile 0.63% Batchfile 3.05% Shell 0.33% TypeScript 0.45% HTML 0.42% Swift 0.83% Dockerfile 0.28% Starlark 0.28% SCSS 0.46% C 0.17%
react-native cordova ios android icons apps mobile

app-icon's Introduction

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

app-icon's People

Contributors

albkn avatar ath0mas avatar bencergazda avatar blackjid avatar cadesalaberry avatar dwmkerr avatar greenkeeper[bot] avatar guardrails[bot] avatar martindoyleuk avatar mindmelting avatar nikostito avatar pabloppp avatar raldred avatar robbiet480 avatar sampsasaarela avatar samypesse avatar sgdesmet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

app-icon's Issues

Splash screens

Hey, would it be possible to generate splash screens with this as well?

docs: improve banner

Something like this would be great:

image

Especially if we can show:

  • Labels
  • Adaptive
  • Android/iOS

At the same time it would be good to do a new blog post to update people on the new adaptive icon features.

Delete old cordova iOS icons

I'm using this tool to generate my iOS icons. I looked into the AppIcon.appiconset/ directory and I see that the default cordova icon files are still in the folder after running the tool. It would be best if those files were removed, because they're no longer needed.

BTW Thanks for creating this tool!

Fonts can break build

We do not yet support explicitly using a font for the label. This means imagemagick relies on the system default (arial on many systems). This means that unit tests will fail, on certain systems, as they rely on external state (the default font).

PR #62 highlights the issue - the test dockerfile relies on us installing windows fonts into a linux env.

feat: add support for osx

Works excellent for iOS - thank you. I am using Cordova for my development and will be trying to build osx versions as well for testing. When I try to build the osx version, I get these errors:

CompileAssetCatalog build/DPP.app/Contents/Resources DPP/Images.xcassets
    cd /Users/svenyonson/github/micronets/dpp-client/platforms/osx
    /Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/svenyonson/github/micronets/dpp-client/platforms/osx/build/DPP.build/Debug/DPP.build/assetcatalog_dependencies --output-partial-info-plist /Users/svenyonson/github/micronets/dpp-client/platforms/osx/build/DPP.build/Debug/DPP.build/assetcatalog_generated_info.plist --app-icon AppIcon --enable-on-demand-resources NO --sticker-pack-identifier-prefix .sticker-pack. --target-device mac --minimum-deployment-target 10.9 --platform macosx --product-type com.apple.product-type.application --compile /Users/svenyonson/github/micronets/dpp-client/platforms/osx/build/DPP.app/Contents/Resources /Users/svenyonson/github/micronets/dpp-client/platforms/osx/DPP/Images.xcassets
/* com.apple.actool.errors */
/Users/svenyonson/github/micronets/dpp-client/platforms/osx/DPP/Images.xcassets: error: The app icon set named "AppIcon" did not have any applicable content.
/* com.apple.actool.document.warnings */
/Users/svenyonson/github/micronets/dpp-client/platforms/osx/DPP/Images.xcassets:./AppIcon.appiconset/(null)[2d][icon-128x128.png]: warning: The app icon set "AppIcon" has 6 unassigned children.
/* com.apple.actool.compilation-results */
/Users/svenyonson/github/micronets/dpp-client/platforms/osx/build/DPP.build/Debug/DPP.build/assetcatalog_generated_info.plist

bug: 'anydpi' adaptive icons are not rendered correctly

When generating adaptive icons, the presence of the anydpi folder seems to cause problems:

image

On one device it appears the icon is zoomed in, on the other it has somehow fallen back to an image I cannot even find in the project!

Reproduction Steps

  • Create a new project Android Studio
  • Use the Image Asset Manager to create adaptive icons'
  • Run app-icon init --adaptive-icons && app-icon generate --adaptive-icons
  • Deploy to a device or emulator

Missing icon sizes for react-native iOS

  • Iphone Notification ios7-11 20pt 2x
  • Iphone Notification ios7-11 20pt 3x
  • Iphone Spotlight - 5,6 Settings - iOS 5 29pt 3x
  • Iphone Spotlight - ios7-11 40pt 3x
  • Iphone App iOS 7-11 60pt 3x
  • Ipad Notifications iOS 7-11 20pt 1x
  • Ipad Notifications iOS 7-11 20pt 2x
  • iPad pro app iOS 9-11 83.5pt 2x
  • App Store iOS 1024pt

Not all icons are generated (delete icon no needed?)

I started my project from a boilerplate (from infinte red) and I used your app like I did in the past but it didn't work on some phone.
After a lot of research I think I found the problem: some icons are not generated.
It is likely that they are not needed, but if present they are used, probably the script should remove those:

  • /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  • /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  • /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  • /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  • /imagzle/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png

Thanks for your amazing work.

SVG support

Hey, the tool looks nice, but seems to lack support for SVG source images. I think it would be really nice to be able to only store SVG images in the code repository, and generate PNG rasters of them on build. SVG images have the benefit of being scalable to any resolution without dithering, and easy to edit by developers without having to install heavy image editing tools. Are there any plans on supporting SVGs in the future?

In the long run, SVG support could even enable support for generating Android Vector Drawable icons.

Support new 'adaptive' icons in Android 8+

Android 8+ has a set of new guidelines for app icons: https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive

The general idea is that you provide an icon and a background colour. The icon has transparency, and is overlaid onto the background colour. The whole thing is then masked by the device, to produce a circle, square, rounded square, etc. To facilitate a circular mask, you can also specify a different icon to use for circular masks.

I'm adding this issue more as a 'nice to have', as it would require a few changes for sure! Some way of asking:

  • whether this behaviour is desired at all (using the 'legacy' launcher icons will still work)
  • if so, whether a different icon file should be used, and what background colour to use

and then the associated changes to the XML files as described in the above link.

Unfortunately I don't have any spare time to dedicate to a PR right now, but thought I'd bring it up in case it was on your roadmap.

Thanks for a great library - it's been a big timesaver for me πŸ˜„

Clean up structure

Some of the basic utils should be put into a utils folder, with adjacent specs. We should have specs for the commandline tool and specs for the main functino

refactor: early validation

See bin/app.icon.js:

operations.push(errorIfMissing(icon, `Source file '${icon}' does not exist. Add the file or specify source icon with the '--icon' parameter.`));

This is a huge smell, there is a whole set of validation/coercion logic (I think in validate.js or something), but it happens after all of this logic to check the flags, which no longer makes sense. I will raise a separate refactor ticket, but just a heads up that this is currently probably the biggest structural issue with the code.

We should also fix issues like:

app-icon label -i one.png -o two.png
# crappy error

and

app-icon something
# should say not a valid command

etc

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 5.15.3 to 5.16.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • βœ… continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).

Release Notes for v5.16.0
  • dfef227 Build: gensite passes rulesMeta to formatter rendering (#11567) (Kevin Partington)
  • c06d38c Fix: Allow HTML formatter to handle no meta data (#11566) (Ilya Volodin)
  • 87a5c03 Docs: func-style: clarify when allowArrowFunctions is used (#11548) (Oliver Joseph Ash)
  • bc3e427 Update: pass rule meta to formatters RFC 10 (#11551) (Chris Meyer)
  • b452f27 Chore: Update README to pull in reviewer data (#11506) (Nicholas C. Zakas)
  • afe3d25 Upgrade: Bump js-yaml dependency to fix Denial of Service vulnerability (#11550) (Vernon de Goede)
  • 4fe7eb7 Chore: use nyc instead of istanbul (#11532) (Toru Nagashima)
  • f16af43 Chore: fix formatters/table test (#11534) (Toru Nagashima)
  • 78358a8 Docs: fix duplicate punctuation in CLI docs (#11528) (Teddy Katz)
Commits

The new version differs by 11 commits.

  • ded2f94 5.16.0
  • ea36e13 Build: changelog update for 5.16.0
  • dfef227 Build: gensite passes rulesMeta to formatter rendering (#11567)
  • c06d38c Fix: Allow HTML formatter to handle no meta data (#11566)
  • 87a5c03 Docs: func-style: clarify when allowArrowFunctions is used (#11548)
  • bc3e427 Update: pass rule meta to formatters RFC 10 (#11551)
  • b452f27 Chore: Update README to pull in reviewer data (#11506)
  • afe3d25 Upgrade: Bump js-yaml dependency to fix Denial of Service vulnerability (#11550)
  • 4fe7eb7 Chore: use nyc instead of istanbul (#11532)
  • f16af43 Chore: fix formatters/table test (#11534)
  • 78358a8 Docs: fix duplicate punctuation in CLI docs (#11528)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

refactor: Node 8

Node 6 reaches end of life 2019-04-30, so let's bump to 8. This will greatly simplify code as we can use async/await.

Using standard icons with Cordova Android 8+ defaulting to the adaptive icons

Before cordova-android 8.0, generating the standard image icons worked fine. However, there now seems to be a default adapative icon with the cordova logo that is being used even when generating the image icons with app-icon generate. There correct icons are in the file, but the ic_launcher.xml files look like this:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/ic_launcher_background" />
    <foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>

Am I overlooking something or is app-icon not handling this correctly?

Wrongly generated icons

The icons iphone-60x60-2x.png and ipad-76x76-2x.png are generated incorrectly, they are equal to the icon iphone-60x60-1x.png and ipad-76x76-1x.png, respectively. This causes, for example, the error message:

"Missing required icon file - The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 7.0."

Doesn't work with yarn

Doesn't add global variable app-icon when using

yarn add global app-icon

Using: yarn 1.3.2

XCode 'Contents.json' Not Update

When building icons for xcode, we actually also need to update the Contents.json file.

Suggest we:

  1. Move the project to JavaScript as we now have a bit more work.
  2. Add unit tests against an integration test folder.
  3. Generate the Contents.json file programatically.

Support generate icons to specific directory

I can't find a way to export the icons to a specific folder.
Only work if there is a react-native project.
I'd like an option to be added to generate the icons for a specific directory passed by parameter.

iOS - `images` fields in Content.json generated in random order

This makes unwanted changes in the AppIcon.appiconset/Content.json file every time after running the script, even if we're running it against the same source icon.

run # 1:

{
  "images": [
    {
      "size": "40x40",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-40x40-2x.png"
    },
    {
      "size": "29x29",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-29x29-3x.png"
    },
    {
      "size": "29x29",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-29x29-2x.png"
    },
    {
      "size": "29x29",
      "idiom": "iphone",
      "scale": "1x",
      "filename": "iphone-29x29-1x.png"
    },
    {
      "size": "20x20",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-20x20-2x.png"
    },
    {
      "size": "20x20",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-20x20-3x.png"
    },
    {
      "size": "20x20",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-20x20-2x.png"
    },
    {
      "size": "20x20",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-20x20-1x.png"
    },
    {
      "size": "40x40",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-40x40-3x.png"
    },
    {
      "size": "57x57",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-57x57-2x.png"
    },
    {
      "size": "60x60",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-60x60-2x.png"
    },
    {
      "size": "57x57",
      "idiom": "iphone",
      "scale": "1x",
      "filename": "iphone-57x57-1x.png"
    },
    {
      "size": "60x60",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-60x60-3x.png"
    },
    {
      "size": "72x72",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-72x72-2x.png"
    },
    {
      "size": "83.5x83.5",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-83.5x83.5-2x.png"
    },
    {
      "size": "29x29",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-29x29-2x.png"
    },
    {
      "size": "50x50",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-50x50-2x.png"
    },
    {
      "size": "76x76",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-76x76-1x.png"
    },
    {
      "size": "29x29",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-29x29-1x.png"
    },
    {
      "size": "72x72",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-72x72-1x.png"
    },
    {
      "size": "40x40",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-40x40-1x.png"
    },
    {
      "size": "76x76",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-76x76-2x.png"
    },
    {
      "size": "50x50",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-50x50-1x.png"
    },
    {
      "size": "40x40",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-40x40-2x.png"
    },
    {
      "size": "1024x1024",
      "idiom": "ios-marketing",
      "scale": "1x",
      "filename": "ios-marketing-1024x1024-1x.png"
    }
  ],
  "info": {
    "version": 1,
    "author": "xcode"
  }
}

run # 2

{
  "images": [
    {
      "size": "40x40",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-40x40-1x.png"
    },
    {
      "size": "29x29",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-29x29-2x.png"
    },
    {
      "size": "29x29",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-29x29-1x.png"
    },
    {
      "size": "60x60",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-60x60-3x.png"
    },
    {
      "size": "60x60",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-60x60-2x.png"
    },
    {
      "size": "57x57",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-57x57-2x.png"
    },
    {
      "size": "57x57",
      "idiom": "iphone",
      "scale": "1x",
      "filename": "iphone-57x57-1x.png"
    },
    {
      "size": "40x40",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-40x40-3x.png"
    },
    {
      "size": "40x40",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-40x40-2x.png"
    },
    {
      "size": "29x29",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-29x29-3x.png"
    },
    {
      "size": "29x29",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-29x29-2x.png"
    },
    {
      "size": "29x29",
      "idiom": "iphone",
      "scale": "1x",
      "filename": "iphone-29x29-1x.png"
    },
    {
      "size": "20x20",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-20x20-2x.png"
    },
    {
      "size": "20x20",
      "idiom": "iphone",
      "scale": "3x",
      "filename": "iphone-20x20-3x.png"
    },
    {
      "size": "20x20",
      "idiom": "iphone",
      "scale": "2x",
      "filename": "iphone-20x20-2x.png"
    },
    {
      "size": "20x20",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-20x20-1x.png"
    },
    {
      "size": "40x40",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-40x40-2x.png"
    },
    {
      "size": "76x76",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-76x76-2x.png"
    },
    {
      "size": "50x50",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-50x50-2x.png"
    },
    {
      "size": "72x72",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-72x72-2x.png"
    },
    {
      "size": "50x50",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-50x50-1x.png"
    },
    {
      "size": "83.5x83.5",
      "idiom": "ipad",
      "scale": "2x",
      "filename": "ipad-83.5x83.5-2x.png"
    },
    {
      "size": "76x76",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-76x76-1x.png"
    },
    {
      "size": "72x72",
      "idiom": "ipad",
      "scale": "1x",
      "filename": "ipad-72x72-1x.png"
    },
    {
      "size": "1024x1024",
      "idiom": "ios-marketing",
      "scale": "1x",
      "filename": "ios-marketing-1024x1024-1x.png"
    }
  ],
  "info": {
    "version": 1,
    "author": "xcode"
  }
}

All the contents are the same, except of that in an other order.

feature: prune

Problem

If there are icons which have not been generated (such as the round icons in issue #71), then even after running generate the expected icon might not be shown on certain devices.

Solution

Warn user when extraneous icons are present, and offer an option to have them removed, meaning only the icons created by app-icon will be in the project.

Specs

The 'prune' feature would have two parts:

Identify Extraneous Icons

When running generate, if extra icons are detected (i.e. icons which have not been generated), then a warning should be shown, such as:

$ app-icon generate.
...
Warning: Some icons in the project have not been replaced with this icon. Your icon might not be shown on all devices. Run generate with the --prune flat to remove these icons.

Prune Extra Icons

If the --prune flag is specified, any extraneous icons should be deleted.

Tasks

  • Lock down technical specs
  • Implement warning on generate
  • Implement --prune flag on generate

Missing parameters are not resulting in errors

Explicit example:

./node_modules/.bin/app-icon label -i base-icon.png -o icon.png --top  --bottom 0

Seems to silently fail. It would be great to have a sensible error message if a required parameter for an action is missing.

android: better handling of round icons

See #71. We now generate round icons - but it might be better to support an icon.round.png image as a template for this, in a similar way to adaptive icon. Then:

$ app-icon init --adaptive-icons --round-icons
$ ls
icon.png
icon.round.png
icon.background.png
icon.foreground.png

The other option would be to simply eliminate round icons and adaptive icons when generating the icons, so that when we are generating icons for projects which have the icons already, we don't get clashes with them.

This also relates to the AndroidManifest, which will explicitly specify if a round icon is actually being used.

refactor: improve error handling

Might be easier to just do:

console.error('An error occurred labelling the icon: ${err}');

Another improvement would be to perhaps standardise the error logging a little, to make sure we print in colour, using chalk, and perhaps even only show the internal error message if a verbose flag like -v is set - but this can happen later.

It also means we could potentially simplify things with something like:

function errorAndExit(errorMessage, internalError, verbose, exitCode) {
   console.error(`${chalk.red('error')}: ${errorMessage}`);
   if (verbose) {
     console.error(`${chalk.red('internal error')}: ${(internalError || '').toString()}`);
   }
   process.exit(exitCode);
}

Also really I should document in the README what the error codes are and actually use separate error codes for separate conditions, but that's an improvement for another time.

Originally posted by @dwmkerr in #97

Windows support

This looks like a fantastic tool, but I get this when trying to run it on windows:

Failed to call 'convert icon.png -resize 167x167 ios\mobile\Images.xcassets\AppIcon.appiconset\ipad-83.5x83.5-2x.png. Error is 'Command failed: convert icon.png -resize 167x167 ios\mobile\Images.xcassets\AppIcon.appiconset\ipad-83.5x83.5-2x.png
Invalid Parameter - -resize

I installed ImageMagick, so I think maybe convert is conflicting with a Windows command?

iOS asset sizes incorrect

Seems to create many of the proper file names, but the sizes are incorrect for the iOS images.xcassets. Xcode errors like:

proj/ios/Hangboard/Images.xcassets: warning: Ambiguous Content: AppIcon.appiconset/ipad-29x29-2x.png is 29x29 but should be 58x58.

the 29x29-1x and 2929-2x are both 29x29.

Xcode 8.3.3
RN 0.47.1

Thanks for the otherwise great tool - Android works great!

icon generation breaks if directory contains a space

Paths supplied to convert are not escaped or quoted, which causes issues if the path contains a space

Failed to call 'convert res/icon/universal/logo.png -resize 1024x1024 platforms/ios/Sample Project/Images.xcassets/AppIcon.appiconset/ios-marketing-1024x1024-1x.png. Error is 'Command failed: convert res/icon/universal/logo.png -resize 1024x1024 platforms/ios/Sample Project/Images.xcassets/AppIcon.appiconset/ios-marketing-1024x1024-1x.png
convert: unable to open image 'platforms/ios/Sample': No such file or directory @ error/blob.c/OpenBlob/3109.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.
convert: unable to open image 'Project/Images.xcassets/AppIcon.appiconset/ios-marketing-1024x1024-1x.png': No such file or directory @ error/blob.c/OpenBlob/3109.
convert: WriteBlob Failed `Project/Images.xcassets/AppIcon.appiconset/ios-marketing-1024x1024-1x.png' @ error/png.c/MagickPNGErrorHandler/1711.

Support configurable search roots

Would be good to be able to specify:

react-native-icon --search ./ios --search ./android/myproject

For example, allowing us to refine in projects where there are lots of other libs etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.