def mobify_image(data):
 fmt = what(None, data)
 if (fmt == 'png'):
  if (not isinstance(data, StringIO)):
   data = StringIO(data)
  im = Image.open(data)
  data = StringIO()
  im.save(data, 'GIF')
  data = data.getvalue()
 return data

def mobify_image ( data ) : fmt = what ( None , data ) if ( fmt == 'png' ) : if ( not isinstance ( data , StringIO ) ) : data = StringIO ( data ) im = Image . open ( data ) data = StringIO ( ) im . save ( data , 'GIF' ) data = data . getvalue ( ) return data
convert png images to gif as the idiotic kindle cannot display some png .