There is no such thing as a misaligned portrait if you're careful...
Your portrait background colour (the beige colour) has to be the FIRST colour in your palette.
The game will take whatever the first colour is and print a line above the unit's portrait with that colour. In vanilla this is always the background colour and it's really hard to see unless you pay close attention to it since it seems everyone but me today confused that line with the scroll-like background. Essentially portraits in-game are of dimension 32x49, where that extra line above the portrait can only be defined by the first palette's colour and nowhere within the spritesheet image itself.
It was never a portrait misalignment. In fact it seems to be caused by a misunderstanding of how the engine works by nearly everyone that thought changing the slot for the background-colour would have no impact.