def crop_from_quad(quad):
    """Return (left, top, right, bottom) from a list of 4 corners."""
    leftmost = min([corner[0] for corner in quad])
    topmost = min([corner[1] for corner in quad])
    rightmost = max([corner[0] for corner in quad])
    bottommost = max([corner[1] for corner in quad])
    return (leftmost, topmost, rightmost, bottommost)