is possible export the image of material preview panel?

I’m thinking in a script and I would like to know if is it possible to export as PNG or JPEG the image of the material that you can see in the preview panel of the material.

I’m only interested in CYCLES materials.

Any idea, advice, etc?

To be more precise, I want to save the image generated in “template_preview” with the material.


  row = box.row()
  o = bpy.context.object
  mat = o.data.materials[0]
  row.template_preview(mat, show_buttons=False)

I want to export the material preview in some way, so maybe there are other options.

I know you could create a sphere, apply the material, render and save the render, but I want to know if it is possible to get the preview image as image object and then use this image to save or anything else.