Convert images to Butano GBA format
Project description
Butano Image Converter
Convert PNG images to Butano GBA-compatible indexed BMP format.
Features
- Convert RGBA PNG to indexed color BMP (16 or 256 colors)
- Automatic transparency handling (first palette color = transparent)
- Size validation for sprites and backgrounds
- JSON metadata generation for Butano
- Sprite sheet support - Split multi-frame images with
--height - Compression options - LZ77, run-length, huffman, or auto
- Interactive TUI for visual file selection and conversion
Installation
pip install img2gba
With TUI support:
pip install img2gba[tui]
Or with pipx:
pipx install img2gba[tui]
Development Installation
To install from source for development:
# Clone the repository
git clone https://github.com/SaraVieira/img2gba.git
cd img2gba
# Create a virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate
# Install with dev dependencies
pip install -e ".[dev]"
Each time you open a new terminal, activate the venv with source venv/bin/activate.
Usage
Basic conversion
img2gba convert player.png
Specify asset type
img2gba convert background.png -t regular_bg
Use 16 colors instead of 256
img2gba convert tiles.png -c 16
Show valid sizes
img2gba sizes sprite
img2gba sizes regular_bg
img2gba sizes affine_bg
Validate an image
img2gba validate player.png -t sprite
Convert a sprite sheet
For an image containing multiple animation frames stacked vertically:
img2gba convert walk_cycle.png -h 32 # Each frame is 32px tall
This generates JSON with "height": 32, telling Butano to split the image.
Use compression
Reduce ROM size with compression (processed during Butano build):
img2gba convert level.png -t regular_bg --compression lz77
Available compression options: none, lz77, run_length, huffman, auto
Interactive TUI
Launch the terminal user interface for visual file browsing:
img2gba tui
Or use the standalone command:
img2gba-tui
TUI Features:
- Browse files with a directory tree
- See image dimensions and validation status in real-time
- Select asset type and color mode
- Configure sprite height and compression
- Convert with a single keypress
Keyboard shortcuts:
C- Convert selected fileR- Refresh directory treeQ- Quit
Valid Sizes
Sprites
| Shape | Sizes |
|---|---|
| Square | 8x8, 16x16, 32x32, 64x64 |
| Wide | 16x8, 32x8, 32x16, 64x32 |
| Tall | 8x16, 8x32, 16x32, 32x64 |
Regular Backgrounds
256x256, 256x512, 512x256, 512x512
Affine Backgrounds
128x128, 256x256, 512x512, 1024x1024
How It Works
- Loads PNG image (RGB or RGBA)
- Detects transparent pixels
- Finds an unused color for transparency
- Replaces transparent pixels with that color
- Quantizes to 16 or 256 colors
- Reorders palette so transparency color is at index 0
- Saves as uncompressed indexed BMP
- Generates JSON metadata file
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file img2gba-0.1.0.tar.gz.
File metadata
- Download URL: img2gba-0.1.0.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
079ff4e02d2ae5c18f099a816737248d2ba6f07a80d5ef9620fda1d3bbc51432
|
|
| MD5 |
9f3b35f20384a1878a6bd9cc2414f141
|
|
| BLAKE2b-256 |
e3b68de5976ce9e78437e8517823ba212aa6f93619bf2ceb3df05b016e8d7a42
|
File details
Details for the file img2gba-0.1.0-py3-none-any.whl.
File metadata
- Download URL: img2gba-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21ec01cbef679b7865547725c911949e4d2eba166933a4723ed25db050eec4ae
|
|
| MD5 |
016d3f91d95152f5226692d5a5e67f3b
|
|
| BLAKE2b-256 |
13021dbde55dff2fb4d5ecfec81c2670bd0a657f6e7435530c2ed538f3681fec
|