I need a function which compares two PIL images of the same size. Let's call them A and B. The result is supposed to be a new image of the same size. If a pixels is the same in both A and B it's supposed to be set to a fixed color (e.g. black), otherwise it's supposed to be set to the same color as B.
Is there a library for implementing this functionality without an expensive loop over all pixels?