Created
September 26, 2011 23:49
-
-
Save philogb/1243805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = new WebPage(), | |
fs = require('fs'), | |
svg, output, size; | |
if (phantom.args.length < 4 || phantom.args.length > 4) { | |
console.log('Usage: svg2Image.js svg width height output'); | |
phantom.exit(); | |
} else { | |
svg = phantom.args[0]; | |
width = phantom.args[1]; | |
height = phantom.args[2]; | |
output = phantom.args[3]; | |
page.viewportSize = { width: 200, height: 200 }; | |
page.content = '<html><head></head><body><svg width="800" height="800"><rect fill="#f00" width="200" height="200"></rect></svg></body></html>'; | |
//page.content = '<html><body>hello world</body></html>'; | |
console.log(page.content); | |
fs.write('something.html', page.content, 'w'); | |
window.setTimeout(function() { | |
page.render(output); | |
window.setTimeout(function() { | |
phantom.exit(); | |
}, 1000); | |
}, 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment