Remap image colors to a constrained palette (CLI + API)
Project description
palette-remap
Remap pixel-art / sprite image colors to a constrained palette — library, CLI, and MCP server.
Examples
| Original | Vanilla Milkshake by Space Sandwich · 16 colors |
Galaxy Flame by Rhoq · 16 colors |
Images produced with:
palette-remap original.png vanilla-milkshake.png \ --palette "#28282e #6c5671 #d9c8bf #f98284 #b0a9e4 #accce4 #b3e3da #feaae4 \ #87a889 #b0eb93 #e9f59d #ffe6c6 #dea38b #ffc384 #fff7a0 #fff7e4" \ --keep-transparency palette-remap original.png galaxy-flame.png \ --palette "#699fad #3a708e #2b454f #111215 #151d1a #1d3230 #314e3f #4f5d42 \ #9a9f87 #ede6cb #f5d893 #e8b26f #b6834c #704d2b #40231e #151015" \ --keep-transparency
Library
from palette_remap import remap_image, parse_palette
palette = parse_palette("#000 #fff #f00")
remap_image("input.png", "out.png", palette)
CLI
palette-remap input.png output.png --palette "#000 #fff #f00"
palette-remap sprite.png result.png --palette-file retro.hex --keep-transparency
MCP server
Exposes three tools so LLMs can remap images, inspect palettes, and analyze image colors. All tools operate on file paths.
Available tools
| Tool | Description |
|---|---|
remap_image_tool |
Remap every pixel to the nearest palette color. Takes image_path + output_path. |
preview_palette |
Parse and list colors from a hex string or file |
list_image_colors |
Rank the most frequent colors in an image. Takes image_path. |
Recommended: pair with mcp/filesystem
Because the tools work with file paths, pair this server with
mcp/filesystem
so the LLM can list directories, check what files exist, and pass correct absolute paths.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/images"]
},
"palette-remap": {
"command": "palette-remap-mcp"
}
}
}
The LLM can then use list_directory from filesystem to discover image paths and feed them directly into remap_image_tool or list_image_colors.
Run options
1 · Direct — after pip install
pip install "palette-remap[mcp]"
claude_desktop_config.json (or equivalent MCP client config):
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/images"]
},
"palette-remap": {
"command": "palette-remap-mcp"
}
}
}
2 · uvx — no install needed
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/images"]
},
"palette-remap": {
"command": "uvx",
"args": ["--from", "palette-remap[mcp]", "palette-remap-mcp"]
}
}
}
3 · Docker
Build once:
docker build -t palette-remap-mcp .
Then in your MCP client config (bind-mount your images folder to /images in both containers):
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--mount", "type=bind,src=/path/to/your/images,dst=/images",
"mcp/filesystem", "/images"
]
},
"palette-remap": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--mount", "type=bind,src=/path/to/your/images,dst=/images",
"palette-remap-mcp"
]
}
}
}
Note: Both containers must mount the same host directory so paths like
/images/sprite.pngresolve identically in both servers.
Dev setup
pip install -e ".[dev,mcp]"
pytest -q
ruff check palette_remap
mypy palette_remap
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 palette_remap-0.1.0.tar.gz.
File metadata
- Download URL: palette_remap-0.1.0.tar.gz
- Upload date:
- Size: 2.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baace487b4fced5a30f466eb7ca62a9309bd53edc3a2d43827263e93e4e032e0
|
|
| MD5 |
575ec0e0f58d8e4adb75da6797a45b81
|
|
| BLAKE2b-256 |
fd73e365a40ea5828b09c4e9955adb0802488b46c7f8ad122027c7609c12b5e6
|
Provenance
The following attestation bundles were made for palette_remap-0.1.0.tar.gz:
Publisher:
publish.yml on joaofreires/palette-remap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
palette_remap-0.1.0.tar.gz -
Subject digest:
baace487b4fced5a30f466eb7ca62a9309bd53edc3a2d43827263e93e4e032e0 - Sigstore transparency entry: 1007568354
- Sigstore integration time:
-
Permalink:
joaofreires/palette-remap@9da2fd4108a4c6d6e45ad7bd7b0e34abec18180d -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/joaofreires
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9da2fd4108a4c6d6e45ad7bd7b0e34abec18180d -
Trigger Event:
release
-
Statement type:
File details
Details for the file palette_remap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: palette_remap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fd70c6ec1fd001cbecedffe90d4593195df17267b45018dedb3e14dc27efc8b
|
|
| MD5 |
a963ac135ee766946be1cf8442c0c8f5
|
|
| BLAKE2b-256 |
6badfafb6b7375c5d9226a613ea2f96dd7761b45a19558a889f2530cde849162
|
Provenance
The following attestation bundles were made for palette_remap-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on joaofreires/palette-remap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
palette_remap-0.1.0-py3-none-any.whl -
Subject digest:
2fd70c6ec1fd001cbecedffe90d4593195df17267b45018dedb3e14dc27efc8b - Sigstore transparency entry: 1007568467
- Sigstore integration time:
-
Permalink:
joaofreires/palette-remap@9da2fd4108a4c6d6e45ad7bd7b0e34abec18180d -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/joaofreires
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9da2fd4108a4c6d6e45ad7bd7b0e34abec18180d -
Trigger Event:
release
-
Statement type: