def convert_png_binary_to_data_url(content):
 if (imghdr.what(None, content) == 'png'):
  return ('data:image/png;base64,%s' % urllib.quote(content.encode('base64')))
 else:
  raise Exception('The given string does not represent a PNG image.')

def convert_png_binary_to_data_url ( content ) : if ( imghdr . what ( None , content ) == 'png' ) : return ( 'data:image/png;base64,%s' % urllib . quote ( content . encode ( 'base64' ) ) ) else : raise Exception ( 'The given string does not represent a PNG image.' )
converts a png image string to a data url .