Skip to main content

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
Original sprite Vanilla Milkshake palette Galaxy Flame palette

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.png resolve identically in both servers.

Dev setup

pip install -e ".[dev,mcp]"
pytest -q
ruff check palette_remap
mypy palette_remap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

palette_remap-0.1.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

palette_remap-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

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

Hashes for palette_remap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 baace487b4fced5a30f466eb7ca62a9309bd53edc3a2d43827263e93e4e032e0
MD5 575ec0e0f58d8e4adb75da6797a45b81
BLAKE2b-256 fd73e365a40ea5828b09c4e9955adb0802488b46c7f8ad122027c7609c12b5e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for palette_remap-0.1.0.tar.gz:

Publisher: publish.yml on joaofreires/palette-remap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for palette_remap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fd70c6ec1fd001cbecedffe90d4593195df17267b45018dedb3e14dc27efc8b
MD5 a963ac135ee766946be1cf8442c0c8f5
BLAKE2b-256 6badfafb6b7375c5d9226a613ea2f96dd7761b45a19558a889f2530cde849162

See more details on using hashes here.

Provenance

The following attestation bundles were made for palette_remap-0.1.0-py3-none-any.whl:

Publisher: publish.yml on joaofreires/palette-remap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page