• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

1000ch/gulp-image: Optimize PNG, JPEG, GIF, SVG images with gulp task.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

1000ch/gulp-image

开源软件地址(OpenSource Url):

https://github.com/1000ch/gulp-image

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-image GitHub Actions Status

Optimize PNG, JPEG, GIF, SVG images with gulp task.

gulp-image result

Install

$ npm install --save-dev gulp-image

External Dendencies

This package includes multiple image-related libraries so that you might be required to install several external dependencies like libjpeg or libpng. Please install them as needed with Homebrew on macOS or apt (Advanced Package Tool) on Linux.

Usage

This is an example of gulpfile.js.

import gulp from 'gulp';
import image from 'gulp-image';

gulp.task('image', () => {
  gulp.src('./fixtures/*')
    .pipe(image())
    .pipe(gulp.dest('./dest'));
});

gulp.task('default', ['image']);

You can pass an object to image() as argument such as following:

gulp.task('image', () => {
  gulp.src('./fixtures/*')
    .pipe(image({
      pngquant: true,
      optipng: false,
      zopflipng: true,
      jpegRecompress: false,
      mozjpeg: true,
      gifsicle: true,
      svgo: true,
      concurrent: 10,
      quiet: true // defaults to false
    }))
    .pipe(gulp.dest('./dest'));
});

Set false for optimizers which you don't want to apply. And you can set concurrent option to limit the max concurrency in execution. You can also set quiet to avoid logging out results for every image processed.

You can configure parameters applied to each optimizers such as following:

gulp.task('image', () => {
  gulp.src('./fixtures/*')
    .pipe(image({
      optipng: ['-i 1', '-strip all', '-fix', '-o7', '-force'],
      pngquant: ['--speed=1', '--force', 256],
      zopflipng: ['-y', '--lossy_8bit', '--lossy_transparent'],
      jpegRecompress: ['--strip', '--quality', 'medium', '--min', 40, '--max', 80],
      mozjpeg: ['-optimize', '-progressive'],
      gifsicle: ['--optimize'],
      svgo: {} // svgo accepts options defined on https://github.com/svg/svgo#configuration
    }))
    .pipe(gulp.dest('./dest'));
});

License

MIT © Shogo Sensui




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap