def save(self, file_name, size=None, **kw_args):
        ext = os.path.splitext(file_name)[1]
        meth_map = {'.ps': 'ps', '.bmp': 'bmp', '.tiff': 'tiff',
                    '.png': 'png', '.jpg': 'jpg', '.jpeg': 'jpg',
                    '.iv': 'iv', '.wrl': 'vrml', '.vrml':'vrml',
                    '.oogl': 'oogl', '.rib': 'rib', '.obj': 'wavefront',
                    '.eps': 'gl2ps', '.pdf':'gl2ps', '.tex': 'gl2ps',
                    '.x3d': 'x3d', '.pov': 'povray'}
        if ext.lower() not in meth_map:
            raise ValueError(
                'Unable to find suitable image type for given file extension.'
            )
        meth = getattr(self, 'save_' + meth_map[ext])
        if size is not None:
            orig_size = self.get_size()
            self.set_size(size)
            meth(file_name, **kw_args)
            self.set_size(orig_size)
            self._record_methods('save(%r, %r)'%(file_name, size))
        else:
            meth(file_name, **kw_args)
            self._record_methods('save(%r)'%(file_name))
Saves rendered scene to one of several image formats
dataset/ETHPy150Open enthought/mayavi/tvtk/pyface/tvtk_scene.py/TVTKScene.save