Grid Sage Forums

Grid Sage Forums

  • May 02, 2024, 07:04:34 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

LINKS: Website | Steam | Wiki

Author Topic: Palette Conversion Script  (Read 1667 times)

NeonCarbide

  • Unaware
  • *
  • Posts: 2
    • View Profile
Palette Conversion Script
« on: September 23, 2021, 12:51:06 AM »

Was just manually typing in palettes into .txts when I thought: 'Ya know, I should script this'

So I did

Here's a link to the script itself
https://gist.github.com/NeonCarbide/97bbf5d7ee105651c768b1171d249d83

The script is written in Python3, and requires the installation of the Pillow library
https://pillow.readthedocs.io/en/stable/installation.html

The script takes two arguments:
  • the filepath of the image to convert to a palette
  • the title of resulting .txt

Example:
Code: [Select]
python3 rexpaint-palette-converter.py C:/Users/ASDF/Desktop/test.png TestPalette
The short of it is that the script takes a 1xN sized .png, N being the number of colours in the palette, and converts it into the .txt format that REXPaint uses for its palettes

The best place I've found for the 1xN palette .pngs is lospec.com/palette-list, otherwise they are very easy to make in Photoshop, Paint, etc.

I hope y'all can make some use of it ^-^
Logged

NeonCarbide

  • Unaware
  • *
  • Posts: 2
    • View Profile
Re: Palette Conversion Script
« Reply #1 on: September 23, 2021, 12:55:45 AM »

Forgot to mention, currently it works for sure with any palette with less than or equal to the 192 colours that REXPaint can display at one time

As for larger palettes, I have yet to do testing, but I do plan on adding the functionality to auto-split large palettes into multiple files
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4320
    • View Profile
    • Cogmind
Re: Palette Conversion Script
« Reply #2 on: September 23, 2021, 02:01:06 AM »

Hey thanks for sharing, NeonCarbide! I'll add a link from the Resources page as well :D

Edit: More recent requests for this feature, and finally another update to REXPaint, led me to include this as an automated feature in 1.70--just drop .gpl files in data/palettes and REXPaint will do the rest!
« Last Edit: January 09, 2024, 09:10:48 PM by Kyzrati »
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon