Package Exports
- spritemint
- spritemint/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spritemint) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
π SpriteMint
Interactive Node.js CLI tool for Unity 2D developers
Normalize sprites, extract sprite sheets, and build new sprite sheets β directly from the terminal, no GUI required.
π Demo
$ spritemint
π SpriteMint β Unity Sprite Processor
? What do you want to do?
β― Normalize Sprites
Extract Sprites from Sheet and Build Horizontal Output
Build Sprite Sheet from Selected PNGsπ Help
Not sure what to do? Just run:
spritemint --helpYou can also use the shorthand:
spritemint -h
This will print a full usage guide directly in your terminal:
SpriteMint β Unity Sprite Processor
USAGE
spritemint Launch interactive menu
spritemint --help Show this help message
spritemint -h Show this help message
COMMANDS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Normalize Sprites β
β Resize PNGs to a square canvas with transparent padding. β
β Aspect ratio is always preserved. β
β Output β <folder>/normalized/ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. Extract Sprites from Sheet & Build Horizontal Output β
β Extract frames from a grid-based sprite sheet, β
β normalize each one, and stitch into a horizontal strip. β
β Output β <folder>/output_horizontal.png β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. Build Sprite Sheet from Selected PNGs β
β Pick individual PNGs and combine them into a sprite sheet. β
β Supports horizontal strip or grid layout. β
β Output β <folder>/spritesheet_output.png β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
REQUIREMENTS
Node.js v18+ | PNG image files⨠Features
1οΈβ£ Normalize Sprites
- π Interactive Selection: Scans a folder and presents PNG files in an interactive checkbox list.
- π Smart Resizing: Resizes each sprite so its largest side fits within the chosen canvas size (256, 512, 1024, or custom).
- πΌοΈ Aspect Ratio Preservation: Never stretches or distorts your art.
- π― Perfect Centering: Centers each sprite on a transparent square canvas with equal padding on all four sides.
- πΎ Clean Output: Saves results directly into a
normalized/folder in your working directory.
2οΈβ£ Extract Sprites from Sheet & Build Horizontal Output
- π§© Grid Extraction: Accepts a sprite sheet PNG and extracts each grid cell using exact pixel coordinates.
- π Smart Auto Detect: Analyses image dimensions to find the most likely grid β prefers square, power-of-two cells. If detection fails, falls back to asking you for rows and columns.
- βοΈ Automatic Trimming: Trims transparent edges from each extracted sprite automatically.
- π Normalization: Normalizes each extracted sprite into an equal-sized square canvas.
- ποΈ Horizontal Compositing: Composites all sprites side-by-side into a single, seamless horizontal PNG strip, perfect for Unity animations.
- π Subfolder Scanning: Searches the current folder and its immediate subdirectories for PNG files.
3οΈβ£ Build Sprite Sheet from Selected PNGs
- βοΈ Interactive File Picker: Select any combination of PNG files from a folder using an interactive checkbox list.
- ποΈ Flexible Layouts: Choose between a Horizontal Strip (all sprites in one row) or a Grid (specify columns, rows calculated automatically).
- π Configurable Cell Size: Pick from 256, 512, or 1024 px β or enter a custom value.
- π― Auto-Centering: Every sprite is trimmed, scaled to fit the cell, and centered with equal padding on all sides.
- πΌοΈ Transparent Canvas: The output sheet is a fully transparent PNG β compositing-ready for Unity or any tool.
- πΎ Saves to Working Directory: Output filename is configurable (defaults to
sheet.png) and is written to wherever you invoked the CLI.
βοΈ Installation
Global Install (Recommended)
To run SpriteMint from anywhere on your machine, install it globally:
npm install -g spritemintThen simply use the command:
spritemintLocal / Development Setup
git clone https://github.com/rakaya07/spritemint.git
cd spritemint
npm install
npm startπΉοΈ Usage Examples
1. Normalize Sprites
Run SpriteMint in your project folder, and it will guide you interactively:
$ spritemint
? What do you want to do?
β― Normalize Sprites
? Select folder containing PNG files:
β― Use current folder
? Select PNG sprites to normalize (use space to select):
β― β hero_idle.png
β hero_walk1.png
β hero_walk2.png
? Output sprite size:
β― 512
β Done! 3 sprites normalized.
Output : /your/project/normalized
Size : 512Γ512px
Files : 3 processed2. Extract Sprites from Sheet
Perfect for converting existing grid sheets into Unity-friendly horizontal strips:
$ spritemint
? What do you want to do?
β― Extract Sprites from Sheet and Build Horizontal Output
? Select PNG file:
β― sheet_characters.png
sprites/hero_sheet.png
? Sprite detection mode:
β― Auto Detect
βΉ Auto-detected grid: 2 rows Γ 2 cols
? Output cell size (px):
β― 512
? Output filename: output-horizontal.png
β Done!
Input : /your/project/sheet_characters.png
Mode : Auto Detect
Grid : 2 rows Γ 2 cols
Sprites : 4 / 4
Cell size: 512Γ512px
Output : /your/project/output-horizontal.png
Canvas : 2048Γ512pxIf Auto Detect cannot determine the grid (non-power-of-two dimensions), SpriteMint will automatically ask you to enter the row and column count manually.
3. Build Sprite Sheet from Selected PNGs
Combine individual PNG files into a new sprite sheet with full control over layout and cell size:
$ spritemint
? What do you want to do?
β― Build Sprite Sheet from Selected PNGs
? Select folder containing PNG files:
β― Use current folder
? Select PNG files to include (use space to select):
β― β hero_idle.png
β hero_run1.png
β hero_run2.png
β hero_run3.png
? Output layout:
β― Grid
? Output cell size (px):
β― 512
? Number of columns (4 images selected): 2
? Output filename: hero_sheet.png
β Done! Sprite sheet built from 4 images.
Images : 4 selected
Layout : Grid
Grid : 2 cols Γ 2 rows
Cell : 512Γ512px
Output : /your/project/hero_sheet.pngπΊοΈ Visual Workflow
Normalizing Individual Sprites
[ RAW SPRITES ]
hero_idle.png
hero_walk1.png
hero_walk2.png
β
βΌ
π SpriteMint
Center & Normalize
β
βΌ
[ NORMALIZED OUTPUT ] normalized/
hero_idle.png (512Γ512, centered on transparent canvas)
hero_walk1.png
hero_walk2.pngExtracting & Building a Horizontal Strip
[ sheet_characters.png ] (1024Γ1024, 2Γ2 grid)
β
βΌ
π SpriteMint
Extract β Normalize
β
βΌ
[ output-horizontal.png ] (2048Γ512 seamless strip)Building a Sheet from Selected PNGs
[ INDIVIDUAL PNGs ]
hero_idle.png
hero_run1.png ββββββββββ
hero_run2.png β π SpriteMint
hero_run3.png ββββββββββ Select β Layout β Composite
β
βΌ
[ hero_sheet.png ] (1024Γ1024, 2Γ2 grid)π Project Structure
spritemint/
βββ bin/
β βββ spritemint.js # CLI entry point
βββ src/
β βββ index.js # Main menu & orchestration
β βββ commands/
β β βββ normalize.js # Flow: Normalize Sprites
β β βββ extractHorizontal.js # Flow: Extract & Composite
β β βββ buildSheet.js # Flow: Build Sprite Sheet
β βββ core/
β β βββ normalizeSprites.js # Logic: normalizing
β β βββ extractAndBuildHorizontal.js # Logic: extraction & compositing
β β βββ buildSpriteSheet.js # Logic: sheet building
β βββ utils/
β βββ folder.js # Shared folder/file selection prompts
β βββ image.js # Shared image processing & SIZE_CHOICES
βββ package.json
βββ README.mdπ£οΈ Roadmap
We are constantly aiming to make SpriteMint better. Planned features include:
- Grid Auto Detection: Detects grid layout from image dimensions (power-of-two cell analysis). Falls back to manual input if detection fails.
- Advanced Auto Sprite Detection: Detect sprites without a rigid grid (using alpha/pixel clustering).
- GUI Version: A standalone Desktop companion app (Electron/Tauri) for visual users.
- WebP/GIF Support: Output configurations for highly-compressed formats.
- Custom Paddings & Offsets: More granular controls over sprite placement on canvas.
π€ Contributing
Contributions are completely welcome and encouraged! Here's how you can help:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
All issues and PRs are appreciated to make this tool better for the open source and game developer community.
π License
This project is licensed under the MIT License. See the LICENSE file for details.