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

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

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

9条回答
  •  甜味超标
    2020-11-22 00:03

    I recently discovered a couple of image tracing libraries for JavaScript that indeed are able to build an acceptable approximation to the bitmap, both size and quality. I'm developing this JavaScript library and CLI :

    https://www.npmjs.com/package/svg-png-converter

    Which provides unified API for all of them, supporting browser and node, non depending on DOM, and a Command line tool.

    For converting logos/cartoon/like images it does excellent job. For photos / realism some tweaking is needed since the output size can grow a lot.

    It has a playground although right now I'm working on a better one, easier to use, since more features has been added:

    https://cancerberosgx.github.io/demos/svg-png-converter/playground/#

提交回复
热议问题