'Append custom user-defined images.
Parameters
fnames : str | list of str
A filename or a list of filenames from which images are read.
Images can be PNG, GIF or SVG.
captions : str | list of str
A caption or a list of captions to the images.
scale : float | None
Scale the images maintaining the aspect ratio.
Defaults to None. If None, no scaling will be applied.
section : str
Name of the section. If section already exists, the images
will be appended to the end of the section.
comments : None | str | list of str
A string of text or a list of strings of text to be appended after
the image.'

def add_images_to_section(self, fnames, captions, scale=None, section='custom', comments=None):

    (fnames, captions, comments) = self._validate_input(fnames, captions, section, comments)
    _check_scale(scale)
    for (fname, caption, comment) in zip(fnames, captions, comments):
        caption = ('custom    plot' if (caption == '') else caption)
        sectionvar = self._sectionvars[section]
        global_id = self._get_id()
        div_klass = self._sectionvars[section]
        img_klass = self._sectionvars[section]
        image_format = os.path.splitext(fname)[1][1:]
        image_format = image_format.lower()
        if (image_format not in ['png', 'gif', 'svg']):
            raise ValueError(("Unknown    image    format.    Only    'png',    'gif'    or    'svg'    are    supported.    Got    %s" % image_format))
        with open(fname, 'rb') as f:
            img = base64.b64encode(f.read()).decode('ascii')
        html = image_template.substitute(img=img, id=global_id, image_format=image_format, div_klass=div_klass, img_klass=img_klass, caption=caption, width=scale, comment=comment, show=True)
        self.fnames.append(('%s-#-%s-#-custom' % (caption, sectionvar)))
        self._sectionlabels.append(sectionvar)
        self.html.append(html)
