def segmentImgs(imgs, cap):
    """
    Segments imgs in n sets of maximum <cap> images.
    :param imgs: Full list of all images
    :param cap: Maximum number of images per set
    :return: List containing n sets of images, where n
            is how many sets of <cap> images can be created.
    """
    if len(imgs) <= cap:
       return [imgs]

    return [imgs[0:cap]] + segmentImgs(imgs[cap:], cap)