Indexed color conversion inconsistencies

I’m having an odd problem with converting RGB images to indexed color mode when I load modified palettes.

My workflow is as follows:

  1. Load an RGB image or animation in Aseprite that has many colors.
  2. Load one of the Aseprite preset color palettes with limited colors (like a 16-color palette).
  3. Convert the image to indexed colors to give it that color-banded look.
  4. Modify the preset palette to better suit my liking, (e.g. pasting a red color where there was a blue color by default.)
  5. Save that modified palette to a .aseprite file for later use with similar images or animations.

Sometimes this works fine. It certainly is consistent with the unmodified preset palettes. It also sometimes works fine with modified palettes. But not all modified palettes work. Once I load these palettes, they put some of the colors in the wrong places - not in the palette itself, but the converted image.

For example, say I have an RGB image of an orange cat with black stripes. Then say I load up a palette that has both orange and black in it, but after I convert the RGB image to indexed color mode, it selects a blue for the stripes instead of black. So I copy and paste the black from the palette over the blue (which I don’t need in the palette), and the stripes turn black. Great.

So I save that palette for future instances of that cat, say for making different animations of it. But when I repeat the process, this time loading up the modified palette I previously saved, it now makes the stripes red, or some other color from the palette that’s not black. The loaded palette appears identical to when I saved it, all the colors are in the right order, but as soon as I put the RGB image into indexed color mode, it doesn’t select the correct colors for all parts of the image. Maybe some are the same, but not all of them. This is true even for identical images.

What am I doing wrong? Should I not be pasting one color from the palette over another? Am I missing a step? Why does it work for some modified palettes, but not others? Any help would be appreciated, as this is the kind of problem that wasn’t obvious immediately, and I’ve already committed myself to custom palettes that are hard to replicate in this use case.

EDIT: After some testing, I assume that what is happening is that Aseprite chooses what it thinks is the best color match when using indexed color mode to convert a 32-bit RGB image to an 8-bit, 16-color image based on the given palette. In other words, it’s one thing to swap colors willy-nilly when I’m working with a single project, but if I then load up that edited palette for a new image, it’s not always going to apply those colors where I want them, even if the images are identical. It’s still going to use the closest match it thinks it has in that edited palette for the conversion, and that may in some cases shift to a new color if it’s closer than the one I changed in said palette to the source image.

So in the above cat example, it’s not going to use black for the stripes unless that’s the closest color in the palette to the original. If it thought the stripes were blue, and there’s, say, a purple in the palette, it might go for that instead of the black.

The only workaround I’ve found for this is to stop editing 16-color palettes and instead create custom palettes from scratch that only have the final colors I want in the image, basing them on the RGB source images. It doesn’t help me for the images I’ve already created (except using other workarounds that don’t 100% work), but at least it’ll allow me options other than sticking with preset palettes. But if anyone does happen to have a solution so I could still use the palettes I edited previously with consistent results, I’d like to hear it.

I think Aesprite picks what it thinks is the nearest colour to use from the palette.
One option would be after you have done all your required artwork, copy all the sprites you want to use the same palette into a single file and then convert to a 16 colour palette you might even want to take it down in steps (128, then 64, 32 colours) as that sometimes help the program to pick the better colours.
Also, while doing these steps down, I normally go through by hand and manually delete colours that are fairly close to each other from the palette (remapping along the way)
I use PhotoShop for colour reduction and Aseprite for clean up and depending on the style you are going for, there will be clean up needed 99% of the time.
Hope that helps.