@hidoo/gulp-task-optimize-image

    0.19.0 • Public • Published

    @hidoo/gulp-task-optimize-image

    Task that optimize image for gulp.

    Installation

    $ npm install --save-dev gulp@next @hidoo/gulp-task-optimize-image

    Usage

    import {task} from 'gulp';
    import optimizeImage from '@hidoo/gulp-task-optimize-image';
    
    task('image', optimizeImage({
      src: '/path/to/images/*.{jpg,jpeg,gif,png,svg,ico}',
      dest: '/path/to/dest'
    }));

    Supported formats

    • PNG

    • JPEG

    • GIF (Partical support)

      • Alpha GIF and Animated GIF are not support.

    API

    gifsicle

    gifsicle plugins for imagemin

    Type: Function

    Examples

    import {gifsicle} from '@hidoo/gulp-task-optimize-image';

    mozjpeg

    mozjpeg plugins for imagemin

    Type: Function

    Examples

    import {mozjpeg} from '@hidoo/gulp-task-optimize-image';

    optipng

    optipng plugins for imagemin

    Type: Function

    Examples

    import {optipng} from '@hidoo/gulp-task-optimize-image';

    svgo

    svgo plugins for imagemin

    Type: Function

    Examples

    import {svgo} from '@hidoo/gulp-task-optimize-image';

    optimizeImage

    return image optimize task

    Parameters

    • options Object option (optional, default {})

      • options.name String task name (use as displayName) (optional, default 'optimize:image')
      • options.src String source path
      • options.dest String destination path
      • options.evenize Boolean apply evenize or not (optional, default false)
      • options.placeholder Boolean generate placeholder image or not (optional, default false)
      • options.webp (Boolean | Object) generate webp or not. use as webp options if object specified. (optional, default false)
      • options.compress Boolean compress file or not (optional, default false)
      • options.compressOptions Array? compress options. see: DEFAULT_OPTIONS. see: gulp-imagemin
      • options.verbose Boolean out log or not (optional, default false)

    Examples

    import {task} from 'gulp';
    import optimizeImage, {
      gifsicle,
      mozjpeg,
      optipng,
      svgo
    } from '@hidoo/gulp-task-optimize-image';
    
    task('image', optimizeImage({
      name: 'image:main',
      src: '/path/to/images/*.{jpg,jpeg,gif,png,svg,ico}',
      dest: '/path/to/dest',
      evenize: true,
      placeholder: true,
      webp: {
        method: 6
      },
      compress: true,
      // Default for this options
      compressOptions: [
        gifsicle({interlaced: true}),
        mozjpeg({quality: 90, progressive: true}),
        optipng({optimizationLevel: 5}),
        svgo()
      ],
      verbose: true
    }));

    Returns Function<Stream>

    Test

    $ yarn test

    License

    MIT

    Keywords

    Install

    npm i @hidoo/gulp-task-optimize-image

    DownloadsWeekly Downloads

    56

    Version

    0.19.0

    License

    MIT

    Unpacked Size

    20.4 kB

    Total Files

    5

    Last publish

    Collaborators

    • hidoo