npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-res-multi-image

v0.10.0

Published

This tool will crop and resize PNG source images into appropriate sizes for modern iOS and Android devices.

Downloads

2

Readme

Resource Generator

This tool will crop and resize JPEG and PNG source images to generate images for modern iOS and Android devices. It will also register the generated images in config.xml so that Cordova projects are updated accordingly.

Install

$ npm install -g cordova-res

Usage

cordova-res must run at the root of a Cordova project, such as:

resources/
├── icon.png
└── splash.png
config.xml
  • resources/icon.png must be at least 1024×1024px
  • resources/splash.png must be at least 2732×2732px

To generate resources with all the default options, just run:

$ cordova-res

cordova-res accepts a platform for the first argument. If specified, resources are generated only for that platform:

$ cordova-res ios

Otherwise, cordova-res looks for platforms in config.xml (e.g. <platform name="ios">) and generates resources only for them.

Documentation

See the help documentation on the command line with the --help flag.

$ cordova-res --help

Adaptive Icons

Android Adaptive Icons are also supported. If you choose to use them, create the following additional file(s):

  • resources/android/icon-foreground.png must be at least 432×432px
  • resources/android/icon-background.png must be at least 432×432px

A color may also be used for the icon background by specifying the --icon-background-source option with a hex color code, e.g. --icon-background-source '#FFFFFF'.

Regular Android icons will still be generated as a fallback for Android devices that do not support adaptive icons.

:memo: Note: Cordova 9+ and cordova-android 8+ is required.

Tips

.gitignore

To avoid committing large generated images to your repository, you can add the following lines to your .gitignore:

resources/android/icon
resources/android/splash
resources/ios/icon
resources/ios/splash
resources/windows/icon
resources/windows/splash

Programmatic API

cordova-res can be used programmatically.

CommonJS Example

const run = require('cordova-res');

await run();

TypeScript Example

run() takes an options object described by the interface Options. If options are provided, resources are generated in an explicit, opt-in manner. In the following example, only Android icons and iOS splash screens are generated.

import { Options, run } from 'cordova-res';

const options: Options = {
  directory: '/path/to/project',
  resourcesDirectory: 'resources',
  logstream: process.stdout, // Any WritableStream
  platforms: {
    android: { icon: { sources: ['resources/icon.png'] } },
    ios: { splash: { sources: ['resources/splash.png'] } },
  },
};

await run(options);

Cordova Reference Documentation

  • Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
  • Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/