gulp-image-sanitizer

Gulp plugin to handle images size


Keywords
gulpplugin, gulp, sharp, image, resize
License
MIT
Install
npm install gulp-image-sanitizer@1.0.0

Documentation

gulp-image-sanitizer

latest version on npm

Setup

npm install --save-dev gulp-image-sanitizer
const { src, dest } = require("gulp");
const imageSanitizer = require("gulp-image-sanitizer");

const images = () =>
  src("source/img/*")
    .pipe(
      imageSanitizer([
        {
          width: 640,
        },
      ])
    )
    .pipe(dest("public/img"));

module.exports.images = images;

Config

width

Type: number
Default: undefined

Desired width of the image in pixels.

height

Type: number
Default: undefined

Desired height of the image in pixels.

maxWidth

Type: number
Default: undefined

Desired max width of the image in pixels. Smaller images are keep untouched.

maxHeight

Type: number
Default: undefined

Desired max height of the image in pixels. Smaller images are keep untouched.

fit

Type: string
Default: 'cover'

How the image should fit inside the specified dimensions.

position

Type: string
Default: 'center'

What or where to focus on when cropping is necessary.

suffix

Type: string
Default: undefined

String to prepend the file extension.