Socket
Socket
Sign inDemoInstall

d3-svg-to-png

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.7 to 0.1.8

33

index.js

@@ -36,7 +36,14 @@ const inlineStyles = target => {

var img = document.createElement('img');
img.setAttribute('src', 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgData))));
img.setAttribute(
'src',
'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgData)))
);
return new Promise(resolve => {
img.onload = () => {
ctxt.drawImage(img, 0, 0);
const file = canvas.toDataURL(`image/${format}`, (format = 'png'), quality);
const file = canvas.toDataURL(
`image/${format}`,
(format = 'png'),
quality
);
resolve(file);

@@ -55,6 +62,18 @@ };

module.exports = async (target, name, { scale = 1, format = 'png', quality = 0.92, download = true, ignore = null, cssinline = 1 } = {}) => {
module.exports = async (
target,
name,
{
scale = 1,
format = 'png',
quality = 0.92,
download = true,
ignore = null,
cssinline = 1
} = {}
) => {
const elt = document.querySelector(target);
//Remember all HTML, as we will modify the styles
//Remember all HTML and CSS, as we will modify the styles
const rememberHTML = elt.innerHTML;
var rememberCSS;

@@ -68,3 +87,4 @@ //Remove unwanted elements

//Set all the css styles inline
if(cssinline === 1){
if (cssinline === 1) {
rememberCSS = elt.style.cssText;
inlineStyles(target, ignore);

@@ -85,2 +105,5 @@ }

elt.innerHTML = rememberHTML;
if (cssinline === 1) {
elt.style.cssText = rememberCSS;
}
return file;

@@ -87,0 +110,0 @@ })

2

package.json
{
"name": "d3-svg-to-png",
"version": "0.1.7",
"version": "0.1.8",
"description": "Converts SVG elements to PNG and other image formats while keeping CSS styles",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,0 +0,0 @@ # d3-svg-to-png

@@ -0,0 +0,0 @@ declare module 'd3-svg-to-png' {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc