#!/usr/bin/python
'Test'
from sys import stdout
from time import sleep
f=file('t.eif','rb')
resultDir='result'
readBytes=''
readingByte=''
tempArr3=['','','']
tempArr8=['','','','','','','','']
#End Of Gif In Eif
startFlag=['\x47','\x49','\x46']
endFlag1=list('49454E44AE426082'.decode('hex'))
endFlag2=list('003B000000000000'.decode('hex'))
gifNum=0
#startGif=False
endGif=False
f.seek(0,0)
while True:
readingByte=f.read(1)
if readingByte=='':
break
tempArr3.pop(0)
tempArr3.append(readingByte)
'''
stdout.write(readingByte.encode('hex')+' ')
byteNum+=1
if byteNum % 10 ==0:
stdout.write('\r\n')
'''
if tempArr3==startFlag:
print gifNum,'Find'
readBytes='GIF'
bytesCount=1
while not endGif:
if bytesCount%10000==0:
print bytesCount
readingByte=f.read(1)
bytesCount+=1
tempArr8.pop(0)
tempArr8.append(readingByte)
readBytes+=readingByte
if tempArr8==endFlag1 or tempArr8==endFlag2:
print gifNum,'End'
endGif=True
#End of a gif
tempArr3=['','','']
tempArr8=['','','','','','','','']
endGif=False
print gifNum,'Write'
r=file(resultDir+'\\'+str(gifNum)+'.gif','wb+')
r.write(readBytes)
r.close()
print gifNum,'Write Over'
readBytes=''
gifNum+=1
f.close()
'Test'
from sys import stdout
from time import sleep
f=file('t.eif','rb')
resultDir='result'
readBytes=''
readingByte=''
tempArr3=['','','']
tempArr8=['','','','','','','','']
#End Of Gif In Eif
startFlag=['\x47','\x49','\x46']
endFlag1=list('49454E44AE426082'.decode('hex'))
endFlag2=list('003B000000000000'.decode('hex'))
gifNum=0
#startGif=False
endGif=False
f.seek(0,0)
while True:
readingByte=f.read(1)
if readingByte=='':
break
tempArr3.pop(0)
tempArr3.append(readingByte)
'''
stdout.write(readingByte.encode('hex')+' ')
byteNum+=1
if byteNum % 10 ==0:
stdout.write('\r\n')
'''
if tempArr3==startFlag:
print gifNum,'Find'
readBytes='GIF'
bytesCount=1
while not endGif:
if bytesCount%10000==0:
print bytesCount
readingByte=f.read(1)
bytesCount+=1
tempArr8.pop(0)
tempArr8.append(readingByte)
readBytes+=readingByte
if tempArr8==endFlag1 or tempArr8==endFlag2:
print gifNum,'End'
endGif=True
#End of a gif
tempArr3=['','','']
tempArr8=['','','','','','','','']
endGif=False
print gifNum,'Write'
r=file(resultDir+'\\'+str(gifNum)+'.gif','wb+')
r.write(readBytes)
r.close()
print gifNum,'Write Over'
readBytes=''
gifNum+=1
f.close()