environment/lib/python2.7/site-packages/IPython/utils/jsonutil.py
def encode_images(format_dict):
    """b64-encodes images in a displaypub format dict
    
    Perhaps this should be handled in json_clean itself?
    
    Parameters
    ----------
    
    format_dict : dict
        A dictionary of display data keyed by mime-type
    
    Returns
    -------
    
    format_dict : dict
        A copy of the same dictionary,
        but binary image data ('image/png' or 'image/jpeg')
        is base64-encoded.
    
    """
    encoded = format_dict.copy()
    pngdata = format_dict.get('image/png')
    if isinstance(pngdata, bytes) and pngdata[:8] == PNG:
        encoded['image/png'] = encodestring(pngdata).decode('ascii')
    jpegdata = format_dict.get('image/jpeg')
    if isinstance(jpegdata, bytes) and jpegdata[:2] == JPEG:
        encoded['image/jpeg'] = encodestring(jpegdata).decode('ascii')
    return encoded
def encode_images(format_dict):
    """b64-encodes images in a displaypub format dict
    
    Perhaps this should be handled in json_clean itself?
    
    Parameters
    ----------
    
    format_dict : dict
        A dictionary of display data keyed by mime-type
    
    Returns
    -------
    
    format_dict : dict
        A copy of the same dictionary,
        but binary image data ('image/png' or 'image/jpeg')
        is base64-encoded.
    
    """
    encoded = format_dict.copy()
    pngdata = format_dict.get('image/png')
    if isinstance(pngdata, bytes) and pngdata[:8] == PNG:
        encoded['image/png'] = encodestring(pngdata).decode('ascii')
    jpegdata = format_dict.get('image/jpeg')
    if isinstance(jpegdata, bytes) and jpegdata[:2] == JPEG:
        encoded['image/jpeg'] = encodestring(jpegdata).decode('ascii')
    return encoded
b64-encodes images in a displaypub format dict
    
    Perhaps this should be handled in json_clean itself?
    
    Parameters
    ----------
    
    format_dict : dict
        A dictionary of display data keyed by mime-type
    
    Returns
    -------
    
    format_dict : dict
        A copy of the same dictionary,
        but binary image data ('image/png' or 'image/jpeg')
        is base64-encoded.