Example #1
0
        def decode_jpeg(encoded,
                        tables=b'',
                        photometric=None,
                        ycbcr_subsampling=None,
                        ycbcr_positioning=None):
            ''' ycbcr resampling is missing in both tifffile and PIL '''
            from StringIO import StringIO
            from PIL import JpegImagePlugin

            return JpegImagePlugin.JpegImageFile(StringIO(tables +
                                                          encoded)).tobytes()
Example #2
0
def read_q_table(file_name):
    jpg = JpegImagePlugin.JpegImageFile(file_name)
    qtable = JpegImagePlugin.convert_dict_qtables(jpg.quantization)
    Y_qtable = qtable[0]
    Y_qtable_2d = np.zeros((8, 8))

    qtable_idx = 0
    for i in range(0, 8):
        for j in range(0, 8):
            Y_qtable_2d[i, j] = Y_qtable[qtable_idx]
            qtable_idx = qtable_idx + 1

    return Y_qtable_2d
Example #3
0
def jpeg_image():
    return JpegImagePlugin.JpegImageFile(create_test_image('jpeg'))