Converts paletted PNG images to binary tileset format. Extracts tiles with configurable dimensions and spacing.
- Converts 256-color indexed PNG images to binary tile data format
- Configurable tile dimensions (e.g., 8x8, 16x16, 32x32)
- Support for tile spacing/padding
- Outputs compact binary format with header
- Debug mode for tile inspection
png2pic [options]-src <path>- Path to the PNG image to convert (default:tileset.png)-dst <path>- Path to the output .pic file (default:tileset.pic)-tile <format>- Tile size in pixels (default:16x16)-spacing <pixels>- Spacing between tiles in pixels (default:0)-debug- Enable debug mode to show tile extraction details
Convert a 16x16 tileset with no spacing:
png2pic -src mytiles.png -dst output.picConvert with 8x8 tiles and 1px spacing:
png2pic -src tileset.png -dst tiles.pic -tile 8x8 -spacing 1Debug mode to inspect tile extraction:
png2pic -src tileset.png -debug- Image must be a PNG file in indexed color mode (paletted)
- Maximum 256 colors in the palette
- Image dimensions should align with tile size + spacing
The output .pic file contains a binary header followed by tile data:
Header (4 bytes):
- Tile width (uint8)
- Tile height (uint8)
- Bytes per tile (uint16, little-endian)
- Total tiles count (uint8)
Data:
- Sequential tile data, row by row
- Each pixel is stored as a palette index (uint8)
go install github.com/laghoule/png2pic@latestdocker pull ghcr.io/laghoule/png2pic:latest
docker run -v $(pwd):/data ghcr.io/laghoule/png2pic -src /data/tileset.png -dst /data/output.picgit clone https://github.com/laghoule/png2pic.git
cd png2pic
go build -o png2pic main.go- Converting tileset graphics for retro game development
- Preparing tile data for embedded systems
- Creating compact binary tile formats for custom engines
- Processing sprite sheets with uniform tile dimensions