def wh_from_pos(pos1, pos2):
    """Calculate width and height from top-left, bottom-right positions"""
    left = pos1[0]
    top = pos1[1]
    w = pos2[0] - pos1[0]
    h = pos2[1] - pos1[1]
    return (left, top, w, h)