Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Image Resize + Watermark + Thumbnails
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
You can’t perform that action at this time.