def _writeGifToFile(fp, images, durations, loops):
 frames = 0
 previous = None
 for im in images:
  if (not previous):
   palette = getheader(im)[1]
   data = getdata(im)
   (imdes, data) = (data[0], data[1:])
   header = getheaderAnim(im)
   appext = getAppExt(loops)
   graphext = getGraphicsControlExt(durations[0])
   fp.write(header)
   fp.write(palette)
   fp.write(appext)
   fp.write(graphext)
   fp.write(imdes)
   for d in data:
    fp.write(d)
  else:
   data = getdata(im)
   (imdes, data) = (data[0], data[1:])
   graphext = getGraphicsControlExt(durations[frames])
   fp.write(graphext)
   fp.write(imdes)
   for d in data:
    fp.write(d)
  previous = im.copy()
  frames = (frames + 1)
 fp.write(';')
 return frames

def _writeGifToFile ( fp , images , durations , loops ) : frames = 0 previous = None for im in images : if ( not previous ) : palette = getheader ( im ) [ 1 ] data = getdata ( im ) ( imdes , data ) = ( data [ 0 ] , data [ 1 : ] ) header = getheaderAnim ( im ) appext = getAppExt ( loops ) graphext = getGraphicsControlExt ( durations [ 0 ] ) fp . write ( header ) fp . write ( palette ) fp . write ( appext ) fp . write ( graphext ) fp . write ( imdes ) for d in data : fp . write ( d ) else : data = getdata ( im ) ( imdes , data ) = ( data [ 0 ] , data [ 1 : ] ) graphext = getGraphicsControlExt ( durations [ frames ] ) fp . write ( graphext ) fp . write ( imdes ) for d in data : fp . write ( d ) previous = im . copy ( ) frames = ( frames + 1 ) fp . write ( ';' ) return frames
given a set of images writes the bytes to the specified stream .