npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svg-to-png-browser

v1.0.2

Published

Convert svg strings to png blob url in the browser.

Downloads

42

Readme

svg-to-png-browser

Async convert an svg string to a png blob url in the browser. Optimzied for Performance. Extra utility function to convert SVG to base64 png.

Used by:

GetAvatars.app

Convert an SVG String to a PNG Blob URL inside the browser

import { convertSVGToPNGUrl } from "svg-to-png-browser"; //function is async

//usage

const pngUrl = await convertSVGToPNGUrl(`<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Home-page" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <g id="Desktop-HD-Copy-8" transform="translate(-488.000000, -338.000000)" fill="#000000" fill-rule="nonzero">
        <g id="refresh-two-counterclockwise-circular-arrows-interface-symbol" transform="translate(488.000000, 338.000000)">
            <path d="M9.24133752,1.67424532 L9.40281916,1.38932843 L10.5517241,0.193421756 C7.75748541,-0.414460502 4.73249324,0.410428994 2.5636169,2.66892385 C-0.47012719,5.826857 -0.811452359,10.7256413 1.54041362,14.2753129 L0.313570728,15.5524075 L4.25193806,16.137931 L3.68944082,12.0383431 L2.6893186,13.0793764 C0.94528256,10.199721 1.27865663,6.34860921 3.68863999,3.83997101 C5.21147536,2.25482677 7.24907279,1.53262049 9.24133752,1.67424532 Z" id="Shape"></path>
            <path d="M17.0959556,1.82813012 L13.0313429,1.24137931 L13.6119007,5.34955982 L14.7409598,4.20839857 C17.0647848,7.14140674 16.8816263,11.4338438 14.1924289,14.1526716 C12.3884139,15.9760534 9.88314246,16.6599148 7.55438799,16.2034503 L6.20689655,17.5653554 C9.32557914,18.5737243 12.8794144,17.8276286 15.3543414,15.3261733 C18.6856708,11.959136 18.8712793,6.61518969 15.9094252,3.02821407 L17.0959556,1.82813012 Z" id="Shape"></path>
        </g>
    </g>
</g>
</svg>`);

console.log(pngUrl); //blob:http://localhost:3000/b42f9ed8-4b6e-40d2-b7a7-5ab11662e54f

Convert an SVG to base64 PNG

import { svgToPngBase64 } from "svg-to-png-browser"; //function is async

//usage
const base64 = await svgToPngBase64(svgString);

console.log(base64);