Save as image on viewport

I’m trying to create script that can save as image from viewport (‘VIEW_3D’ area).
The problem is, bpy.ops.image.save_as() only accepting ‘IMAGE_EDITOR’ area context.

Do anyone know how can I workaround this? :spin:

you mean a screenshot?

No, I mean image, any image. Actually I’m doing an addon that can save image texture used by material on viewport. The use-case is the user paint/edit images mapped on objects and save them, all of them are happen on the viewport.