Resource Generator
This tool will crop and resize PNG source images to generate images for modern iOS and Android devices.
cordova-res
must run at the root of a standard Cordova project setup, such as:
resources/
├── icon.png
└── splash.png
config.xml
resources/icon.png
must be at least 1024×1024pxresources/splash.png
must be at least 2732×2732px
Install
$ npm install -g cordova-res
Usage
See the help documentation on the command line with the --help
option.
$ cordova-res --help
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,
platforms: {
android: { icon: { sources: ['resources/icon.png'] } },
ios: { splash: { sources: ['resources/splash.png'] } },
},
};
await run(options);