Render the image and save as a file

I’ve been trying this for about an hour now, and I fail miserably :frowning:

I have created a Panel with a few values (mostly integers) and a button. The values simply decide which objects will be hidden from the renderer and the 3D view (obj.hide, obj.hide_render).

As an operator action (for a button on a panel) I’d like to invoke a renderer using the settings from the Render tab, but I have no idea how to start the renderer. Also, I’d like to save the rendered image automatically to a file. My panel and operators seem to work (I can print debug messages etc.) but I just don’t get how to access the renderer.

Can anyone point me in the right direction?