Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@agragregra
Created October 10, 2016 09:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save agragregra/e977cc7238477f35c3b055aa78bea6b0 to your computer and use it in GitHub Desktop.
Save agragregra/e977cc7238477f35c3b055aa78bea6b0 to your computer and use it in GitHub Desktop.
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