@jeansoft/cocos-icon-gen
v0.3.4
Published
Generate iOS, macOS, and Windows app icons for Cocos Creator projects from a single source image
Readme
@jeansoft/cocos-icon-gen
Generate iOS, macOS, and Windows app icons for Cocos Creator projects from a single source image.
Install
pnpm add -g @jeansoft/cocos-icon-genOr use directly via npx:
npx @jeansoft/cocos-icon-gen <source-image> [output-dir]Usage
cocos-icon-gen <source-image> [output-dir] [options]<source-image>— Source image path (PNG, JPEG, WebP, etc.; min 1024×1024 recommended for ICNS)output-dir— Output directory (default: current directory.)-h, --help— Show help-v, --version— Show version number-i, --ios— iOS icons only-m, --mac— macOS icon only-w, --win— Windows icon only
Omitting platform flags generates all three.
Examples
# All three icon sets
cocos-icon-gen icon.png
# Custom output directory
cocos-icon-gen icon.png ./my-icons
# iOS only
cocos-icon-gen --ios icon.png
# macOS and Windows
cocos-icon-gen --mac --win icon.pngOutput Layout
| Platform | Path |
| -------- | ---- |
| iOS | proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset/ (20 PNGs) |
| macOS | proj.ios_mac/mac/Icon.icns (ICNS, 12 sizes 16×16 to 1024×1024) |
| Windows | proj.win32/res/game.ico (multi-ICO: 16, 32, 48, 64, 128, 256) |
API
import {
genIosIcons, // (sourcePath, outDir?) => Promise<void>
genMacIcon, // (sourcePath, outFile?) => Promise<void>
genWinIcon, // (sourcePath, outFile?) => Promise<void>
IOS_ICONS, // IconInfo[] — 20 icon definitions
IOS_ICON_NAMES,// string[]
IOS_OUTPUT, // 'proj.ios_mac/ios/Images.xcassets/AppIcon.appiconset'
MAC_OUTPUT, // 'proj.ios_mac/mac/Icon.icns'
WIN_OUTPUT, // 'proj.win32/res/game.ico'
parseIconSize, // (filename: string) => number
} from '@jeansoft/cocos-icon-gen';
import type { IconInfo } from '@jeansoft/cocos-icon-gen';
// { filename: string; size: number }// Default outputs match Cocos Creator project layout:
await genIosIcons('icon.png'); // proj.ios_mac/ios/...
await genIosIcons('icon.png', 'output/ios');
await genMacIcon('icon.png'); // proj.ios_mac/mac/Icon.icns
await genMacIcon('icon.png', 'output/mac/Icon.icns');
await genWinIcon('icon.png'); // proj.win32/res/game.ico
await genWinIcon('icon.png', 'output/win/game.ico');Development
pnpm install
pnpm build
pnpm typecheck
pnpm testLicense
MIT
