def METHOD_NAME(self, im, segmentation=None, records=None):
    """
    Adds an image to the transcription interface, optionally filling in
    information from a list of ocr_record objects.
    Args:
        im (PIL.Image): Input image
        segmentation (dict): Output of the segment method.
        records (list): A list of ocr_record objects.
    """
    im_str = get_im_str(im)
    logger.info('Adding page {} with {} lines'.format(im_str, len(segmentation) if segmentation else len(records)))
    page = {}
    fd = BytesIO()
    im.save(fd, format='png', optimize=True)
    page['index'] = self.page_idx
    self.page_idx += 1
    logger.debug('Base64 encoding image')
    page['img'] = 'data:image/png;base64,' + base64.b64encode(fd.getvalue()).decode('ascii')
    page['lines'] = []
    if records:
        logger.debug('Adding records.')
        self.text_direction = segmentation['text_direction']
        for record, bbox in zip(records, segmentation['boxes']):
            page['lines'].append({'index': self.line_idx, 'text': record.prediction,
                                  'left': 100*int(bbox[0]) / im.size[0],
                                  'top': 100*int(bbox[1]) / im.size[1],
                                  'width': 100*(bbox[2] - bbox[0])/im.size[0],
                                  'height': 100*(int(bbox[3]) - int(bbox[1]))/im.size[1],
                                  'bbox': '{}, {}, {}, {}'.format(int(bbox[0]),
                                                                  int(bbox[1]),
                                                                  int(bbox[2]),
                                                                  int(bbox[3]))})
            self.line_idx += 1
    elif segmentation:
        logger.debug('Adding segmentations.')
        self.text_direction = segmentation['text_direction']
        for bbox in segmentation['boxes']:
            page['lines'].append({'index': self.line_idx,
                                  'left': 100*int(bbox[0]) / im.size[0],
                                  'top': 100*int(bbox[1]) / im.size[1],
                                  'width': 100*(bbox[2] - bbox[0])/im.size[0],
                                  'height': 100*(int(bbox[3]) - int(bbox[1]))/im.size[1],
                                  'bbox': '{}, {}, {}, {}'.format(int(bbox[0]),
                                                                  int(bbox[1]),
                                                                  int(bbox[2]),
                                                                  int(bbox[3]))})
            self.line_idx += 1
    else:
        raise KrakenInputException('Neither segmentations nor records given')
    self.pages.append(page)