Created
February 17, 2015 20:20
-
-
Save thomd/5c54eda06ac8ddf331b9 to your computer and use it in GitHub Desktop.
simple image server
This file contains hidden or 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
// EXAMPLE | |
// curl localhost:8080/image.png/400 | |
// | |
var http = require('http'); | |
var spawn = require('child_process').spawn; | |
http.createServer(function(req, res) { | |
var params = req.url.split('/'); | |
var path = __dirname + '/' + params[1]; | |
var size = params[2]; | |
var convert = spawn('convert', [path, '-resize', size, '-']); | |
res.writeHead(200); | |
convert.stdout.pipe(res); | |
}).listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment