def jpeg_header_length(byte_array):
    """Finds the length of a jpeg header, given the jpeg data in byte array format"""
    result = 417
    for i in range(len(byte_array) - 3):
        if byte_array[i] == 0xFF and byte_array[i + 1] == 0xDA:
            result = i + 2
            break
    return result