#!/usr/bin/env python3 """Export every installed Aseprite GPL palette into Bilta Gilata1 JSON.""" import json from pathlib import Path SOURCE = Path("/Applications/Aseprite.app/Contents/Resources/data") OUTPUT = Path(__file__).with_name("palettes.json") def parse(path): colors = [] for line in path.read_text(errors="replace").splitlines(): fields = line.strip().split() if len(fields) >= 3 and all(field.isdigit() for field in fields[:3]): colors.append("#" + "".join(f"{min(255, int(value)):02x}" for value in fields[:3])) return colors def main(): palettes = {} for path in sorted(SOURCE.rglob("*.gpl")): colors = parse(path) if colors: key = path.stem.lower().replace("_", "-").replace(" ", "-") palettes[key] = {"colors": colors, "source": str(path.relative_to(SOURCE))} OUTPUT.write_text(json.dumps({"format": "bilta-gilata1-palettes", "count": len(palettes), "palettes": palettes}, indent=2)) print(f"Exported {len(palettes)} Aseprite palettes to {OUTPUT}") if __name__ == "__main__": main()