-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
40 lines (35 loc) · 1.24 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var gulp = require('gulp');
var resize = require('gulp-image-resize');
var parallel = require('concurrent-transform');
var debug = require('gulp-debug');
var rename = require('gulp-rename');
var CORES = require('os').cpus().length;
var path = require('path');
function register(paths) {
var absolutePath = path.resolve(paths);
console.log('Working on: ' + absolutePath);
gulp.task('previews', function() {
return gulp.src([absolutePath + '/*.jpg', absolutePath + '/*.jpeg', absolutePath + '/*.png'])
.pipe(parallel(resize({
width: 1500,
quality: 0.5
}), CORES))
.pipe(gulp.dest(absolutePath + '/previews'))
.pipe(debug({
title: 'Created'
}));
});
gulp.task('thumbnails', ['previews'], function() {
return gulp.src([absolutePath + '/previews/*.jpg', absolutePath + '/*.jpeg', absolutePath + '/*.png'])
.pipe(parallel(resize({
width: 200
}), CORES))
.pipe(gulp.dest(absolutePath + '/thumbs'))
.pipe(debug({
title: 'Created'
}));
});
gulp.task('prep', ['previews', 'thumbnails']);
gulp.start('prep');
}
module.exports = register;