I think I get it, but don't ask me what the picture is about. Anyway, you make two images and where there is a difference the transparency will equal to the difference, then the colour in the blackbackgrounded image is divided by the alpha value. Simple, but smart. Could you make your tool convert to png immediately? That would save even more time.