def tile_images(img1, img2, mask1, mask2, opts):
w1, h1 = img1.size<EOL>w2, h2 = img2.size<EOL>if opts.orientation == '<STR_LIT>':<EOL><INDENT>opts.orientation = pick_orientation(img1, img2, opts.spacing)<EOL><DEDENT>B, S = opts.border, opts.spacing<EOL>if opts.orientation == '<STR_LIT>':<EOL><INDENT>w, h = (B + w1 + S + w2 + B, B + max(h1, h2) + B)<EOL>pos1 = (B, (h - h1) // <NUM_LIT:2>)<EOL>pos2 = (B + w1 + S, (h - h2) // <NUM_LIT:2>)<EOL>separator_line = [(B + w1 + S//<NUM_LIT:2>, <NUM_LIT:0>), (B + w1 + S//<NUM_LIT:2>, h)]<EOL><DEDENT>else:<EOL><INDENT>w, h = (B + max(w1, w2) + B, B + h1 + S + h2 + B)<EOL>pos1 = ((w - w1) // <NUM_LIT:2>, B)<EOL>pos2 = ((w - w2) // <NUM_LIT:2>, B + h1 + S)<EOL>separator_line = [(<NUM_LIT:0>, B + h1 + S//<NUM_LIT:2>), (w, B + h1 + S//<NUM_LIT:2>)]<EOL><DEDENT>img = Image.new('<STR_LIT>', (w, h), opts.bgcolor)<EOL>img.paste(img1, pos1, mask1)<EOL>img.paste(img2, pos2, mask2)<EOL>ImageDraw.Draw(img).line(separator_line, fill=opts.sepcolor)<EOL>return img<EOL>
Combine two images into one by tiling them.

    ``mask1`` and ``mask2`` provide optional masks for alpha-blending;
    pass None to avoid.

    Fills unused areas with ``opts.bgcolor``.

    Puts a ``opts.spacing``-wide bar with a thin line of ``opts.sepcolor``
    color between them.

    ``opts.orientation`` can be 'lr' for left-and-right, 'tb' for
    top-and-bottom, or 'auto' for automatic.