Save NSImage as template to file

Hello
If we set an NSImage.template = YES, it becomes grayscale, automatically follows dark mode, and so on. Is there a way to save it as a png as a template, the way it would be rendered by a system?
Save NSImage as template to file
 
 
Q