import imghdr


def validate_image_file(filename, image_format):
    """ Determine if an image file is valid

    Args:
        filename (:obj:`str`): path to image file
        image_format (:obj:`ImageFormat`): image format

    Returns:
        :obj:`tuple`:

            * nested :obj:`list` of :obj:`str`: nested list of errors
            * nested :obj:`list` of :obj:`str`: nested list of warnings
    """
    if imghdr.what(filename) == image_format.value:
        return [], []
    else:
        return [['`{}` is not a valid {} image.'.format(filename, image_format.name)]], []