Convert SVG to image (JPEG, PNG, etc.) in the browser

前端 未结 9 1046
春和景丽
春和景丽 2020-11-21 23:38

I want to convert SVG into bitmap images (like JPEG, PNG, etc.) through JavaScript.

9条回答
  •  借酒劲吻你
    2020-11-22 00:07

    Here is how you can do it through JavaScript:

    1. Use the canvg JavaScript library to render the SVG image using Canvas: https://github.com/gabelerner/canvg
    2. Capture a data URI encoded as a JPG (or PNG) from the Canvas, according to these instructions: Capture HTML Canvas as gif/jpg/png/pdf?

提交回复
热议问题