You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thumbsup/src/steps/actions.js

34 lines
1.2 KiB
JavaScript

const downsize = require('thumbsup-downsize')
const fs = require('fs-extra')
exports.createMap = function (opts) {
const thumbSize = opts.thumbSize || 120
const largeSize = opts.largeSize || 1000
const defaultOptions = {
quality: opts.photoQuality,
args: opts.gmArgs
}
const watermark = (!opts.watermark) ? null : {
file: opts.watermark,
position: opts.watermarkPosition
}
const thumbnail = Object.assign({}, defaultOptions, {
height: thumbSize,
width: thumbSize
})
const large = Object.assign({}, defaultOptions, {
height: largeSize,
watermark: watermark,
animated: true
})
return {
'fs:copy': (task, done) => fs.copy(task.src, task.dest, done),
'fs:symlink': (task, done) => fs.symlink(task.src, task.dest, done),
'photo:thumbnail': (task, done) => downsize.image(task.src, task.dest, thumbnail, done),
'photo:large': (task, done) => downsize.image(task.src, task.dest, large, done),
'video:thumbnail': (task, done) => downsize.still(task.src, task.dest, thumbnail, done),
'video:poster': (task, done) => downsize.still(task.src, task.dest, large, done),
'video:resized': (task, done) => downsize.video(task.src, task.dest, {}, done)
}
}