{"_id":"@svg-fns/svg2img","_rev":"3-1a3a2771e6a6d7867d76c879bc88b1be","name":"@svg-fns/svg2img","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.0":{"name":"@svg-fns/svg2img","version":"0.0.0","keywords":["svg","svg convert","svg base64","svg blob","svg datauri","svg rasterize","svg to image","svg export","svg utils","browser","nodejs","utilities","svg-fns","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"author":{"url":"https:/mayank-chaudhari.vercel.app","name":"Mayank Kumar Chaudhari"},"license":"MPL-2.0","_id":"@svg-fns/svg2img@0.0.0","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/convert/#readme","bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"dist":{"shasum":"4f0d9e0e0e3bdebaa06b77e16db8d8b86a954b1a","tarball":"https://registry.npmjs.org/@svg-fns/svg2img/-/svg2img-0.0.0.tgz","fileCount":14,"integrity":"sha512-9hj1BlZGabIhd8l93qge6rA+B0xb0+EDGWVA/1mHQ93Y+85aX4XQkuEptCqKogI0/BNW0Rzcedjw7idRknyy1w==","signatures":[{"sig":"MEUCIEhd8PnycrAzgyXi67rEccKtwJS17U2NbPU85Yq+GZvMAiEAv1e4rdKWNuiFX11+IRlLoREzpdtRfx4goQxSwWnSMEk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47186},"main":"./dist/index.js","_from":"file:svg-fns-svg2img-0.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"},"./dist/*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"}},"funding":[{"url":"https://github.com/sponsors/svg-fns","type":"github"},{"url":"https:/github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"/tmp/955576d1adaa9a799faa409a7364c323/svg-fns-svg2img-0.0.0.tgz","_integrity":"sha512-9hj1BlZGabIhd8l93qge6rA+B0xb0+EDGWVA/1mHQ93Y+85aX4XQkuEptCqKogI0/BNW0Rzcedjw7idRknyy1w==","repository":{"url":"git+https://github.com/svg-fns/svg-fns.git","type":"git"},"_npmVersion":"10.8.2","description":"Utility functions to convert SVGs into different formats (Base64, Blob, Data URI, raster images). Works in client and server with optimal performance.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","sharp":"^0.34.4","typescript":"^5.9.2","@types/node":"^24.5.0","@svg-fns/utils":"^1.0.0","esbuild-plugin-rdi":"^0.0.0"},"peerDependencies":{"sharp":"^0.34.4"},"peerDependenciesMeta":{"sharp":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/svg2img_0.0.0_1758816388104_0.9944326976009881","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@svg-fns/svg2img","version":"0.1.0","keywords":["svg","svg convert","svg base64","svg blob","svg datauri","svg rasterize","svg to image","svg export","svg utils","browser","nodejs","utilities","svg-fns","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"author":{"url":"https:/mayank-chaudhari.vercel.app","name":"Mayank Kumar Chaudhari"},"license":"MPL-2.0","_id":"@svg-fns/svg2img@0.1.0","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/convert/#readme","bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"dist":{"shasum":"b7cfb75449a9f0f75a67173b4cd2f665263d0f00","tarball":"https://registry.npmjs.org/@svg-fns/svg2img/-/svg2img-0.1.0.tgz","fileCount":14,"integrity":"sha512-Qyw6mpwoU2znr6aRGrUix8WN/qvXguvac4HfQSbq/oC3G5CEjUtMb0ygxxIGf2Uemfu0obg1WfX0WQfJnq9QXw==","signatures":[{"sig":"MEYCIQC1gfhnuIdd6bK+EaIePzac1bvc9GSVM5ODYGXNXGQawwIhAIOOqarQP1YBzGPBK/rM1A2rEbi32+1TPzjoeSjclxlV","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51398},"main":"./dist/index.js","_from":"file:svg-fns-svg2img-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"},"./dist/*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"}},"funding":[{"url":"https://github.com/sponsors/svg-fns","type":"github"},{"url":"https:/github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"/tmp/830a9db142b355e2246b23c93465ba42/svg-fns-svg2img-0.1.0.tgz","_integrity":"sha512-Qyw6mpwoU2znr6aRGrUix8WN/qvXguvac4HfQSbq/oC3G5CEjUtMb0ygxxIGf2Uemfu0obg1WfX0WQfJnq9QXw==","repository":{"url":"git+https://github.com/svg-fns/svg-fns.git","type":"git"},"_npmVersion":"10.8.2","description":"Utility functions to convert SVGs into different formats (Base64, Blob, Data URI, raster images). Works in client and server with optimal performance.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","sharp":"^0.34.4","typescript":"^5.9.2","@types/node":"^24.5.0","@svg-fns/utils":"^1.1.0","esbuild-plugin-rdi":"^0.0.0"},"peerDependencies":{"sharp":"^0.34.4"},"peerDependenciesMeta":{"sharp":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/svg2img_0.1.0_1759045233716_0.1296936117744396","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@svg-fns/svg2img","author":{"name":"Mayank Kumar Chaudhari","url":"https:/mayank-chaudhari.vercel.app"},"private":false,"version":"0.2.0","description":"Utility functions to convert SVGs into different formats (Base64, Blob, Data URI, raster images). Works in client and server with optimal performance.","license":"MPL-2.0","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/svg-fns/svg-fns.git"},"bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/convert/#readme","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"},"./dist/*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"}},"devDependencies":{"@types/node":"^24.6.1","esbuild-plugin-rdi":"^0.0.0","sharp":"^0.34.4","tsup":"^8.5.0","typescript":"^5.9.3","@svg-fns/utils":"^2.0.0"},"funding":[{"type":"github","url":"https://github.com/sponsors/svg-fns"},{"type":"github","url":"https:/github.com/sponsors/mayank1513"}],"keywords":["svg","svg convert","svg base64","svg blob","svg datauri","svg rasterize","svg to image","svg export","svg utils","browser","nodejs","utilities","svg-fns","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"peerDependencies":{"sharp":"^0.34.4"},"peerDependenciesMeta":{"sharp":{"optional":true}},"scripts":{"build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","dev":"tsup --watch","typecheck":"tsc --noEmit"},"_id":"@svg-fns/svg2img@0.2.0","_integrity":"sha512-XuRBr/6kTnnYNNCgTtHA12Tebtf6hAmvZzXYdG1Ha2K3Npz6IemvfQ5VIhTk5buieHaxaIPPPSl14P2WRNGKFQ==","_resolved":"/tmp/0d8ced1a055dd77922ac50f48756a729/svg-fns-svg2img-0.2.0.tgz","_from":"file:svg-fns-svg2img-0.2.0.tgz","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-XuRBr/6kTnnYNNCgTtHA12Tebtf6hAmvZzXYdG1Ha2K3Npz6IemvfQ5VIhTk5buieHaxaIPPPSl14P2WRNGKFQ==","shasum":"da7a9e6494bb73987c88c7768483e1ff218bdeb5","tarball":"https://registry.npmjs.org/@svg-fns/svg2img/-/svg2img-0.2.0.tgz","fileCount":14,"unpackedSize":55188,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGMLuT20bzj8jWOASQQbqRZA7AgVvj0umyoBiWyijqsMAiAgeG35r2bsukMHhQFus7i9ALHbldX71UTg1XAwPeElCw=="}]},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"directories":{},"maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svg2img_0.2.0_1762068985568_0.8518372472433737"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-25T16:06:27.942Z","modified":"2025-11-02T07:36:25.986Z","0.0.0":"2025-09-25T16:06:28.289Z","0.1.0":"2025-09-28T07:40:33.887Z","0.2.0":"2025-11-02T07:36:25.789Z"},"bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"author":{"name":"Mayank Kumar Chaudhari","url":"https:/mayank-chaudhari.vercel.app"},"license":"MPL-2.0","homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/convert/#readme","keywords":["svg","svg convert","svg base64","svg blob","svg datauri","svg rasterize","svg to image","svg export","svg utils","browser","nodejs","utilities","svg-fns","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"repository":{"type":"git","url":"git+https://github.com/svg-fns/svg-fns.git"},"description":"Utility functions to convert SVGs into different formats (Base64, Blob, Data URI, raster images). Works in client and server with optimal performance.","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"readme":"# @svg-fns/svg2img <img src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 40px\"/>\n\n[![test](https://github.com/svg-fns/svg-fns/actions/workflows/test.yml/badge.svg)](https://github.com/svg-fns/svg-fns/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/svg-fns/svg-fns/graph/badge.svg)](https://codecov.io/gh/svg-fns/svg-fns)\n[![Version](https://img.shields.io/npm/v/@svg-fns/svg2img.svg?colorB=green)](https://www.npmjs.com/package/@svg-fns/svg2img)\n[![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/@svg-fns/svg2img.svg)](https://www.npmjs.com/package/@svg-fns/svg2img)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/@svg-fns/svg2img)\n\n> **Convert SVG to PNG, JPEG, WebP, AVIF, Data URL, Blob, or Buffer — isomorphic, tree-shakeable, and typed.**\n\n---\n\n## ✨ Overview\n\n`@svg-fns/svg2img` makes it effortless to transform raw SVG strings into modern image formats.\n\n- **Isomorphic** → works in Browser (Canvas API) & Node.js (Sharp).\n- **Tree-shakeable** → zero-bloat, minimal runtime.\n- **Typed** → written in TypeScript for DX.\n- **Modern formats** → PNG, JPEG, WebP, AVIF.\n- **Resizing & fitting** → scale, width/height, cover/contain/fill.\n\n---\n\n## 🚀 Quick Start\n\n```ts\nimport { svgToDataUrl } from \"@svg-fns/svg2img\";\n\nconst mySvg = `<svg width=\"100\" height=\"100\" xmlns=\"http://www.w3.org/2000/svg\">\n  <circle cx=\"50\" cy=\"50\" r=\"40\" fill=\"royalblue\" />\n</svg>`;\n\n// Convert to PNG Data URL at 200px wide\nconst pngDataUrl = await svgToDataUrl(mySvg, { format: \"png\", width: 200 });\n\nconst img = document.createElement(\"img\");\nimg.src = pngDataUrl;\ndocument.body.appendChild(img);\n```\n\n---\n\n## 📦 Installation\n\n```sh\n# Browser or universal usage\npnpm add @svg-fns/svg2img\nnpm install @svg-fns/svg2img\nyarn add @svg-fns/svg2img\n```\n\n👉 **For Node.js** (Buffer conversion), install [sharp](https://github.com/lovell/sharp):\n\n```sh\npnpm add sharp\n```\n\n---\n\n## 🔑 Core API\n\n### Browser\n\n- **`svgToBlob(svg, options)`** → `Blob`\n- **`svgToDataUrl(svg, options)`** → `string (data URL)`\n\n### Node.js\n\n- **`svgToBuffer(svg, options)`** → `Buffer`\n- **`svgToDataUrlNode(svg, options)`** → `string (data URL)`\n\n### Universal\n\n- **`svgToDataUrl(svg, options)`** → auto-detects env → returns Data URL\n\n---\n\n## 🎨 Examples\n\n### 1. Browser → JPEG Blob\n\n```ts\nimport { svgToBlob } from \"@svg-fns/svg2img\";\n\nconst blob = await svgToBlob(mySvg, {\n  format: \"jpeg\",\n  quality: 0.8,\n  background: \"#fff\",\n});\n\nconst url = URL.createObjectURL(blob);\ndocument.querySelector(\"img\")!.src = url;\n```\n\n---\n\n### 2. Node.js → WebP file\n\n```ts\nimport { svgToBuffer } from \"@svg-fns/svg2img\";\nimport { writeFile } from \"fs/promises\";\n\nconst buffer = await svgToBuffer(mySvg, {\n  format: \"webp\",\n  width: 500,\n  height: 500,\n  fit: \"contain\",\n});\n\nawait writeFile(\"output.webp\", buffer);\n```\n\n---\n\n## ⚙️ Options\n\n```ts\ninterface SvgConversionOptions {\n  format?: \"png\" | \"jpeg\" | \"webp\" | \"avif\" | \"svg\";\n  quality?: number; // 0–1, default: 0.92\n  width?: number; // px\n  height?: number; // px\n  scale?: number; // multiplier, default: 1\n  background?: string; // e.g. \"#fff\"\n  fit?: \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n}\n```\n\n- **`format`** → output type (default: `\"svg\"`).\n- **`fit`** → how to resize (cover/crop vs contain/letterbox).\n- **`scale`** → for high-DPI rendering.\n- **`background`** → useful for JPEG (no alpha).\n\n---\n\n## 🤝 Contributing\n\nWe welcome issues & PRs!\n\n- [Open an Issue](https://github.com/svg-fns/svg-fns/issues)\n- [Submit a PR](https://github.com/svg-fns/svg-fns/pulls)\n\n---\n\n## ❤️ Sponsor\n\nIf `@svg-fns/svg2img` saves you time, consider [sponsoring](https://github.com/sponsors/mayank1513).\nYour support fuels maintenance, features & community growth.\n\n---\n\n## License\n\nThis library is licensed under the MPL-2.0 open-source license.\n\n> <img src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 20px\"/> Please enroll in [our courses](https://mayank-chaudhari.vercel.app/courses) or [sponsor](https://github.com/sponsors/mayank1513) our work.\n\n<hr />\n\n<p align=\"center\">\n  with 💖 by <a href=\"https://mayank-chaudhari.vercel.app\" target=\"_blank\">Mayank Kumar Chaudhari</a>\n</p>\n","readmeFilename":"README.md"}