def make_image_url(reg, path, name='', tag='', digest='', empty_name_ok=False):
    """Construct a string from (path, name, tag)
	
	Essentially the opposite of parse_image_url()"""
    if reg:
        path = reg + '/' + path
        if path.endswith('/'):
            path = path[:-1]
    if name:
        if tag:
            if digest:
                image = name + ':' + tag + '@' + digest
            else:
                image = name + ':' + tag
        elif digest:
            image = name + '@' + digest
        else:
            image = name
    elif not empty_name_ok and (path or tag or digest):
        raise ValueError('Invalid image url: missing image name')
    else:
        image = ''
    if path:
        return path + '/' + image
    else:
        return image
