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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@city41/gba-convertpng

v0.0.29

Published

Converts png images to GBA tile format

Readme

HEY! I don't recommend using this tool just yet. Please wait until it gets to 1.0.0 at least.

I am currently heavily in development of my GBA game and hacking at this tool as I go. My ultimate plan is a really cohesive and easy to use tool for GBA graphics, but I'm not quite there yet.

GBA Convert png

This is a nodejs based tool for converting png images to the tile data format used in GBA games.

Installation

Make sure you have a recent version of nodejs installed.

npm install -g @city41/gba-convertpng
or
yarn global add @city41/gba-convertpng

Usage

convertpng runs off a json spec file.

gba-convertpng myGBAResources.json

This json file provides everything that is needed to convert pngs to GBA data. Here is an example

{
  "outputDir": "./output",
  "sprites": [
    {
      "file": "cursor.png",
      "frames": 2
    }
  ],
  "backgrounds": [
    {
      "file": "myBg.png"
    }
  ]
}

This is about as simple as the spec file gets. It will load up cursor.png and myBg.png and convert them into tile data for the asz80 assembler in files cursor.tiles.asm, cursor.palette.asm, myBg.tiles.asm, myBg.palette.asm and myBg.map.asm.

And for example, cursor.palette.asm looks like this

.dw 0x7c1f,0x28c4,0x7fff,0x76d2,0,0,0,0,0,0,0,0,0,0,0,0

Ideal for dropping into a game that uses the asz80 assembler.

File paths

All of the image paths specified in the json spec are relative to the spec file. So in the above example, the pngs would be in the same directory as the spec file.

The same is true for outputDir, this is a directory path relative to the json spec file. This directory must exist.

Other source code formats

At the root of the json spec you can add format to specify C or pyz80 output.

C output

{
  "outputDir": "./output",
  "format": "C",
  "sprites": [
    ...

C output is a standard C array, either bytes (tile data) or words (palettes). For example with the above json spec, the C output for the cursor palette would be cursor.palette.c.inc, and the contents would be

{ 0x7c1f,0x28c4,0x7fff,0x76d2,0,0,0,0,0,0,0,0,0,0,0,0 }

The idea is to include it into your C source using the preprocessor, something like:

const u8 cursorTiles[] =
#include "cursor.tiles.c.inc"
;
const u16 cursorPalette[] =
#include "cursor.palette.c.inc"
;

(I do almost no C development, so the C output might not be ideal. Let me know if you have any ideas here.)

pyz80 output

{
  "outputDir": "./output",
  "format": "pyz80",
  "sprites": [
    ...

If you specify "pyz80" as the format, the output will look like this, for example cursor.palette.asm

dw 0x7c1f,0x28c4,0x7fff,0x76d2,0,0,0,0,0,0,0,0,0,0,0,0

The only difference from asz80 is the lack of the leading period.

Other options

Sprite frames

All sprite entries must specify how many frames of animation are contained within the png. Each frame should be horizontally laid out within the image.

For example this png is a sprite that has four frames of animation

sprite with four frames

Even if a sprite just has a single frame of animation, then "frames": 1 still needs to be specified.

shared palette

A group of sprites can share a palette like this

{
  "outputDir": "./output",
  "sprites": [
    {
      "sharedPalette": [
        {
          "file": "cursor.png",
          "frames": 2
        },
        {
          "file": "enemy.png",
          "frames": 1
        }
      ],
      "name": "global"
    }
  ]
}

In this case convert-png will combine the colors of both sprites into a single 15 color palette, and output it as global.shared.palette.[asm|c.inc], the tile output files for the sprites will be the same as before.

Trim palette

You can add "trimPalette": true to any sprite or background. With this specified, the palette output data will only be as big as needed. For example the palette above with all the trailing zeros becomes this

.dw 0x7c1f,0x28c4,0x7fff,0x76d2

Force palette

Normally convertpng will examine the pngs and figure out an optimal palette. If you need your data to conform to an existing palette, specify it with "forcePalette": "<palette-file>"

This should be a png image that is 15x1, each pixel being a color in the palette.

With forced palettes, imagemagick will be used to push the png files to match this palette. If you create the pngs using that palette, this won't cause any changes. But if you don't, you might be surprised how much your sprite has changed.

With a forced palette, the color indexes within the forced palette will be honored. So if within your palette you have a red at index 1, then the tile data for the sprites/backgrounds will be 1 whenever that red pixel is needed.

Publishing

gba-convertpng uses semantic versioning

Publishing a new version is done by bumping the version in package.json

yarn version
yarn version v1.22.19
info Current version: 0.0.2
question New version: 0.0.3
info New version: 0.0.3
Done in 16.19s.

git push
git push --tags

Once the Publish action notices the version has changed, it will run a build and publish to npm.