Beispiel #1
0
 def test_inject_then_extract(self):
     for fname in self.fnames[:2]:
         mygif = Gif()
         mygif.read_from_file(fname)
         b = os.urandom(mygif.available_bytes() - 4)
         gif_inject(mygif, b)
         data = gif_extract(mygif)
         print(b.hex())
         print(data.hex())
         self.assertEqual(b, data)
Beispiel #2
0
        elif code == stop:
            break
        if code < next_code:
            index_list = code_table[code]
            for c in index_list:
                index_stream.append(c)
            if prevCode != clear:
                code_table.append(code_table[prevCode] + (index_list[0], ))
                next_code += 1
        else:
            index_list = code_table[prevCode]
            for c in index_list:
                index_stream.append(c)
            index_stream.append(index_list[0])
            code_table.append(index_list + (index_list[0], ))
            next_code += 1
        prevCode = code
    return index_stream


if __name__ == "__main__":

    fname = '../gifs/sample_2_animation.gif'

    mygif = Gif()
    mygif.read_from_file(fname)

    print('available bytes in first frame = {}'.format(
        mygif.get_frames()[0].available_bytes()))
    print('total available bytes = {}'.format(mygif.available_bytes()))