Skip to content

Instantly share code, notes, and snippets.

@jimthoburn
Last active June 21, 2017 20:33
Show Gist options
  • Save jimthoburn/9799536fc0294c027e8b03063ae56061 to your computer and use it in GitHub Desktop.
Save jimthoburn/9799536fc0294c027e8b03063ae56061 to your computer and use it in GitHub Desktop.
Gulp Resize Images, Example
// https://github.com/gulpjs/gulp
var gulp = require('gulp');
// https://www.npmjs.com/package/gulp-image-resize
var imageResize = require('gulp-image-resize');
var parallel = require("concurrent-transform");
var os = require("os");
const SIZES = [384, 512, 768, 1024, 1536, 2048];
function generateImages(size) {
gulp.src("images/original/*.{jpg,png}")
.pipe(parallel(
imageResize({ width : size }),
os.cpus().length
))
.pipe(gulp.dest("images/" + size + "-wide"));
}
gulp.task("default", function() {
SIZES.forEach(generateImages);
});
{
"name": "resize-images",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "jim@jimthoburn.com",
"license": "MIT",
"devDependencies": {
"concurrent-transform": "^1.0.0",
"gulp": "^3.9.1",
"gulp-image-resize": "^0.12.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment