Created
December 22, 2011 20:41
-
-
Save mattbaker/1511774 to your computer and use it in GitHub Desktop.
Send a PNG of a red square to STDOUT using node.js and convert
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
/* converttest.js: Send a PNG of a red square to STDOUT | |
* ex. node converttest.js > test.png | |
*/ | |
var convert = require('child_process').spawn("convert", ["svg:", "png:-"]), | |
svgsrc = '<svg><rect height="100" width="100" style="fill:red;"/></svg>'; | |
convert.stdout.on('data', function (data) { | |
process.stdout.write(data); | |
}); | |
convert.stdin.write(svgsrc); | |
convert.stdin.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It does not work for me on Win7. Most probably because of a bug in the #spawn of Node.