layout | title | date | excerpt | categories |
---|---|---|---|---|
post |
SVG to Image |
2020-12-30 13:04:20 -0800 |
Convert and download SVG to image (PNG or JPEG) on the frontend. |
svg image png jpeg jsfiddle javascript |
The JSFiddle is inspired by the article "Convert SVG to PNG using your browser".
The steps to save SVG to image are:
The improvements made in my example are:
- Added the ability to resize SVG in canvas
- Added the option to update the filename
- Added the option to change the file extension from
png
tojpeg
- Used HTML5 form validation
- Prevented memory leaks by cleaning up event listeners
- Improved accessibility
- Stopped supporting older browsers
Here are some sample SVG's you can use to test against the converter: