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

muncher

v0.0.13

Published

Generate sprite sheets from the command line

Downloads

13

Readme


:sparkles: Features

  • Reads .piskel and .png files and turns them into sprite sheets using Texture Packer

  • Can add a horizontally flipped copy to the output


How to use

Example usage with npx:

npx muncher --input sprites/ --output output/spritesheet

If your project includes a package.json, then the preferred way is to include muncher as a dev dependency:

npm i --save-dev muncher

or

yarn add --dev muncher

You can then add a script to your package.json scripts section:

"munch": "muncher --input sprites/ --output output/spritesheet"

CLI flags

input - The source folder. Contains .png and .piskel files that you want to turn into a sprite sheet.

output - The output filename. A .json and a .png sprite sheet file will be created.

flip - Every file name that ends with either left or right will also generate a horizontally flipped copy. (Optional)

config - Path to config file. (Optional)

Texture packer options

All options that you can pass to the texturepacker CLI you can also pass to muncher. For example:

muncher --input sprites --output output/spritesheet --extrude 5 --multipack

Available options

Config file

Instead of passing options as flags on the command line, you can specify them in a config file:

npx muncher --config muncher.json

The format has to be .json

muncher.json

{
  "input": "sprites",
  "output": "output/spritesheet",
  "flip": true,
  "extrude": 5
}

Example output

png

example.png => example.png

With flip enabled:

player/walk-right.png => player/walk-right.png and player/walk-left.png

piskel

Since piskel files can contain multiple images (frames), the texture name will include the frame index as a suffix:

example.piskel => example-1.png

With flip enabled:

example-right.piskel => example-right-1.png and example-left-1.png

Example

input folder structure

sprites/
├── multiple-layers.piskel
├── green/
│   └── green.png
├── muncher/
│   ├── piskel/
│   │   └── muncher-right.piskel
│   └── png/
│       └── muncher-right.png
└── square/
    ├── square1.png
    └── square2.png
muncher --input sprites/ --output output/spritesheet --flip

output texture names

multiple.layers.png
green/green.png
muncher/piskel/muncher-right-0.png
muncher/piskel/muncher-left-0.png
muncher/png/muncher-right.png
muncher/png/muncher-left.png
square/square1.png
square/square2.png

Requirements

Texture Packer CLI

  • Download Texture Packer.

  • Install the command line tool from the application UI.


imagemagick

MacOS

You can install imagemagick with homebrew:

brew install imagemagick

Linux

https://medium.com/@sanjaywrites/install-latest-version-of-imagemagick-in-ubuntu-16-04-c406ddea1973


Node.js

nodejs.org - Version 11 or higher


Recipes

Multiple output sprite sheets

Try to only use one output spritesheet for as long as possible. This is better for performance reasons. If your spritesheet becomes too big, try to separate it by layer in your game. For example, 'background' and 'foreground'. In that case, you can add multiple muncher commands to a script and execute that one.

Example:

./munch.sh

muncher --input example/sprites/background/ --output example/output/background
muncher --input example/sprites/foreground/ --output example/output/foreground

Develop

Workflow

  1. Make changes

  2. yarn build-test - Builds, packs, installs to example folder and executes muncher there.

  3. If everything works: push master or make a PR