using custom python scripts with PIL.Image. Load the image, compute/extract the palette, reorder it if you need to (you will need to!!), and rebuild the binary pics using the palette you want.
In my pacman project there's an example to extract bobs and sprites with a fixed palette. All those external programs don't care about paletted images or the order of the palettes, resulting in headaches...
this script
https://github.com/jotd666/pacman500...ets/convert.py
uses bitplanelib from
https://github.com/jotd666/amiga68ktools and builds .bin files (sprites, bobs, bobs bitplanes) from one big png file and a json file describing the various frames.
this method allows to edit your pics using gimp (with png and a fixed palette) and as long as the palettes in your script & in the png match, the order of the palette in the png isn't important.
Also used that for my Supercars 2 AGA conversion and a few other hacks.