<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_image_format(filename):
 """Get the image format."""

    image = None
    bad_image = 1
    image_format = NONE_FORMAT
    sequenced = False
    try:
        bad_image = Image.open(filename).verify()
        image = Image.open(filename)
        image_format = image.format
        sequenced = _is_image_sequenced(image)
    except (OSError, IOError, AttributeError):
        pass

    if sequenced:
        image_format = gif.SEQUENCED_TEMPLATE.format(image_format)
    elif image is None or bad_image or image_format == NONE_FORMAT:
        image_format = ERROR_FORMAT
        comic_format = comic.get_comic_format(filename)
        if comic_format:
            image_format = comic_format
        if (Settings.verbose > 1) and image_format == ERROR_FORMAT and \
                (not Settings.list_only):
            print(filename, "doesn't look like an image or comic archive.")
    return image_format