def image_from_file(self, filename):

        # Although QPixmap can load SVG directly, it does not respect the
        # default size, so we use a QSvgRenderer to get the default size.
        if filename.endswith(('.svg', '.SVG')):
            renderer = QtSvg.QSvgRenderer(filename)
            pixmap = QtGui.QPixmap(renderer.defaultSize())
            pixmap.fill(QtCore.Qt.transparent)
            painter = QtGui.QPainter(pixmap)
            renderer.render(painter)

        else:
            pixmap = QtGui.QPixmap(filename)

        return pixmap
Creates an image from the data in the specified filename.
dataset/ETHPy150Open enthought/pyface/pyface/ui/qt4/resource_manager.py/PyfaceResourceFactory.image_from_file