Files
paku/img2pal.py
T
Raimon @ quifisraimon 8a770de885 - [NEW] Minimapa en el editor
- [NEW] Diferent marcador
- [NEW] Més habitacions
2026-10-01 12:44:07 +02:00

24 lines
556 B
Python

#!/usr/bin/env python3
from PIL import Image
import sys
if len(sys.argv) != 3:
print(f"Uso: {sys.argv[0]} entrada.png salida.pal")
sys.exit(1)
img = Image.open(sys.argv[1]).convert("RGB")
num_colors = img.width * img.height
with open(sys.argv[2], "w") as f:
f.write("JASC-PAL\n")
f.write("0100\n")
f.write(f"{num_colors}\n")
for y in range(img.height):
for x in range(img.width):
r, g, b = img.getpixel((x, y))
f.write(f"{r} {g} {b}\n")
print(f"Escritos {num_colors} colores en {sys.argv[2]}")