I don't have time to implement a commandline tool, but it is quite possible.
I did the following in code:
If there was an overlaid tile (tile flags & 1 ^ overlaynum) != 0 then cloned the tile (and set alternate tile to this clone).
I've removed the transparent color from the original tile (i made the transparent pixel take one of its neighbours color, future improvements could base the color selection on all neighbours).
If dithering removal was also enabled, i've made all orphaned pixels transparent in the cloned tile.
Some terms
orphaned pixel: a non-transparent pixel with all neighbours transparent
transparent color: it is the 0. palette index
tile flags: they exist for all tile, if a tile is overlaid, the overlay is marked by setting the overlay's bit to 1. The first overlay's bit number is 2 (1<<1), because the main overlay (the area graphics) is the first.
I hope this helps.
I'll soon update the DLTCEP sources on the gemrb site too, so one can see the C source.