def color(self, img1, img2):
import colorsys<EOL>p1 = list(img1.getdata())<EOL>p2 = list(img2.getdata())<EOL>for i in range(len(p1)):<EOL><INDENT>r1, g1, b1, a1 = p1[i]<EOL>r1 = r1 / <NUM_LIT><EOL>g1 = g1 / <NUM_LIT><EOL>b1 = b1 / <NUM_LIT><EOL>h1, s1, v1 = colorsys.rgb_to_hsv(r1, g1, b1)<EOL>r2, g2, b2, a2 = p2[i]<EOL>r2 = r2 / <NUM_LIT><EOL>g2 = g2 / <NUM_LIT><EOL>b2 = b2 / <NUM_LIT><EOL>h2, s2, v2 = colorsys.rgb_to_hsv(r2, g2, b2)<EOL>r3, g3, b3 = colorsys.hsv_to_rgb(h2, s2, v1)<EOL>r3 = int(r3*<NUM_LIT:255>)<EOL>g3 = int(g3*<NUM_LIT:255>)<EOL>b3 = int(b3*<NUM_LIT:255>)<EOL>p1[i] = (r3, g3, b3, a1)<EOL><DEDENT>img = Image.new("<STR_LIT>", img1.size, <NUM_LIT:255>)<EOL>img.putdata(p1)<EOL>return img<EOL>
Applies the color blend mode.

        Colorize image img1 with image img2.
        The color filter replaces the hue and saturation of pixels in img1
        with the hue and saturation of pixels in img2.
        Returns a composite image with the alpha channel retained.