mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Rename "roles" to "units". Put units in their own folders.
This commit is contained in:
parent
7d9d64ddcb
commit
3a9b193f68
63 changed files with 105 additions and 105 deletions
26
lib/units/storage/plugins/image/task/transform.js
Normal file
26
lib/units/storage/plugins/image/task/transform.js
Normal 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)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue