def overlay(self, img1, img2):
p1 = list(img1.getdata())<EOL>p2 = list(img2.getdata())<EOL>for i in range(len(p1)):<EOL><INDENT>p3 = ()<EOL>for j in range(len(p1[i])):<EOL><INDENT>a = p1[i][j] / <NUM_LIT><EOL>b = p2[i][j] / <NUM_LIT><EOL>if j == <NUM_LIT:3>:<EOL><INDENT>d = min(a,b)<EOL><DEDENT>elif a > <NUM_LIT:0.5>: <EOL><INDENT>d = <NUM_LIT:2>*(a+b-a*b)-<NUM_LIT:1><EOL><DEDENT>else: <EOL><INDENT>d = <NUM_LIT:2>*a*b            <EOL><DEDENT>p3 += (int(d*<NUM_LIT:255>),)<EOL><DEDENT>p1[i] = p3<EOL><DEDENT>img = Image.new("<STR_LIT>", img1.size, <NUM_LIT:255>)<EOL>img.putdata(p1)<EOL>return img<EOL>
Applies the overlay blend mode.

        Overlays image img2 on image img1.
        The overlay pixel combines multiply and screen:
        it multiplies dark pixels values and screen light values.
        Returns a composite image with the alpha channel retained.