JSPM

spritemint

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 3
    • Score
      100M100P100Q54127F
    • License MIT

    Interactive CLI tool for normalizing, extracting, and building Unity sprite sheets

    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

    npm version License: MIT Node.js CLI Tool

    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 --help

    You 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

    To run SpriteMint from anywhere on your machine, install it globally:

    npm install -g spritemint

    Then simply use the command:

    spritemint

    Local / 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 processed

    2. 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Γ—512px

    If 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.png

    Extracting & 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:

    1. Fork the repository.
    2. Create your feature branch (git checkout -b feature/AmazingFeature).
    3. Commit your changes (git commit -m 'Add some AmazingFeature').
    4. Push to the branch (git push origin feature/AmazingFeature).
    5. 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.

    Built with ❀️ for Game Developers & the Unity Community.