From what I can see you have to define the exact coordinates of the pixel that needs rendering. The same goes for Image::XPM and others.
I hate to say this, but, do you have to use Perl for this solution? A lot of graphic packages have batch conversion tools these days. You could make changes to the colour pallete and batch convert a number of images from there.