Add an app for resizing images. Still needs rate limiting, and still trying to decide how to pass the correct URL to the app.

This commit is contained in:
Simo Kinnunen
2014-05-20 19:00:53 +09:00
parent 9e4dc269a2
commit e56d757cde
7 changed files with 158 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
var gm = require('gm')
var Promise = require('bluebird')
module.exports = function(stream, options) {
return new Promise(function(resolve, reject) {
var transform = gm(stream)
if (options.gravity) {
transform.gravity(options.gravity)
}
if (options.crop) {
transform.geometry(options.crop.width, options.crop.height, '^')
transform.crop(options.crop.width, options.crop.height, 0, 0)
}
transform.stream(function(err, stdout) {
if (err) {
reject(err)
}
else {
resolve(stdout)
}
})
})
}