def is_jpeg(data):
    "\n    Check whether a bytes object (or similar) contains JPEG (JFIF) data.\n    Returns False for truncated files.\n    Taken from simplejpeg.is_jpeg, but less strict because it doesn't check EOI, as most JPEG viewers don't really throw error for missing EOI.\n\n    :param data: JPEG (JFIF) data\n    :return: True if JPEG\n    "
    return (data[:2] == b'\xff\xd8')
Check whether a bytes object (or similar) contains JPEG (JFIF) data.
Returns False for truncated files.
Taken from simplejpeg.is_jpeg, but less strict because it doesn't check EOI, as most JPEG viewers don't really throw error for missing EOI.

:param data: JPEG (JFIF) data
:return: True if JPEG
def is_jpeg(data):
    "\n    Check whether a bytes object (or similar) contains JPEG (JFIF) data.\n    Returns False for truncated files.\n    Taken from simplejpeg.is_jpeg, but less strict because it doesn't check EOI, as most JPEG viewers don't really throw error for missing EOI.\n\n    :param data: JPEG (JFIF) data\n    :return: True if JPEG\n    "
    return (data[:2] == b'\xff\xd8')