'Convert base64 svg to base64 png [duplicate]

I'm currently saving a base64 svg string into the database. Now I need to save a png file to the database, which should also be base64 encoded. Is there a way to convert an svg string or a base64 encoded svg string to a base64 encoded png string?
This is what I'm doing right now:

let svg = this.$refs.chart.chart.getSVG()
let encodedChart = window.btoa(svg)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source