Comparing version 1.0.1 to 1.1.0
@@ -23,9 +23,16 @@ "use strict"; | ||
var dimensions = getSvgDimensions(page); | ||
page.viewportSize = { | ||
width: Math.round(dimensions.width * scale), | ||
height: Math.round(dimensions.height * scale) | ||
}; | ||
if (!dimensions.usesViewBox) { | ||
page.zoomFactor = scale; | ||
try { | ||
var dimensions = getSvgDimensions(page); | ||
page.viewportSize = { | ||
width: Math.round(dimensions.width * scale), | ||
height: Math.round(dimensions.height * scale) | ||
}; | ||
if (dimensions.shouldScale) { | ||
page.zoomFactor = scale; | ||
} | ||
} catch (e) { | ||
console.error("Unable to calculate dimensions."); | ||
console.error(e); | ||
phantom.exit(); | ||
return; | ||
} | ||
@@ -50,2 +57,3 @@ | ||
var height = parseFloat(el.getAttribute("height")); | ||
var hasWidthOrHeight = width || height; | ||
var viewBoxWidth = el.viewBox.animVal.width; | ||
@@ -75,4 +83,4 @@ var viewBoxHeight = el.viewBox.animVal.height; | ||
return { width: width, height: height, usesViewBox: usesViewBox }; | ||
return { width: width, height: height, shouldScale: hasWidthOrHeight || !usesViewBox }; | ||
}); | ||
} |
{ | ||
"name": "svg2png", | ||
"description": "A SVG to PNG converter, using PhantomJS.", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenic.me)", | ||
@@ -21,6 +21,6 @@ "license": "WTFPL", | ||
"devDependencies": { | ||
"chai": "~1.9.0", | ||
"chai": "~1.9.1", | ||
"jshint": "~2.4.3", | ||
"mocha": "~1.17.1" | ||
"mocha": "~1.18.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5890
94
1