Last active
April 2, 2017 13:39
-
-
Save inpromotion/434c66e63a023dbcca27f909e4d9ba54 to your computer and use it in GitHub Desktop.
Gulpfile для ресайза и минификации изображений
This file contains 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
var src = "___library/7-kazan/1/*"; | |
var dst = "_ready"; | |
var gulp = require('gulp'), | |
imagemin = require('gulp-imagemin'), | |
cache = require('gulp-cache'), | |
del = require('del'), | |
imageResize = require('gulp-image-resize'), | |
watermark = require("gulp-watermark"), | |
rename = require("gulp-rename"); | |
gulp.task('image', ['imagesmall'], function() { | |
return gulp.src(src) | |
.pipe(imageResize({ | |
width : 1920, | |
height : 1080, | |
crop : true, | |
upscale : true | |
})) | |
.pipe(watermark({ | |
image: "watermark.png" | |
})) | |
.pipe(rename(function (path) {path.basename = path.basename.replace('Depositphotos_', '')})) | |
.pipe(rename(function (path) {path.basename = path.basename.replace('_original', '')})) | |
.pipe(cache(imagemin())) | |
.pipe(gulp.dest(dst)); | |
}); | |
gulp.task('imagesmall', function() { | |
return gulp.src(src) | |
.pipe(imageResize({ | |
width : 760, | |
height : 428, | |
crop : true, | |
upscale : true | |
})) | |
.pipe(watermark({ | |
image: "watermark.png" | |
})) | |
.pipe(rename(function (path) {path.basename = path.basename.replace('Depositphotos_', '')})) | |
.pipe(rename(function (path) {path.basename = path.basename.replace('_original', '')})) | |
.pipe(cache(imagemin({progressive: true}))) | |
.pipe(gulp.dest(dst + '/small')); | |
}); | |
gulp.task('clearcache', function () { return cache.clearAll(); }); | |
gulp.task('cleaready', function() { return del.sync(dst); }); | |
gulp.task('default', ['image']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment