image-min

2019-10-11

image-min是什么

什么是image-min,Minify GIF, JPEG and PNG images

image-min使用教程帮助文档

build status">imagemin Build Status

Minify images seamlessly


Gumlet is helping make open source sustainable by sponsoring Sindre Sorhus.[

Optimised Image Delivery made simple](https://www.gumlet.com)


Install

$ npm install imagemin

Usage

const imagemin = require('imagemin');
const imageminJpegtran = require('imagemin-jpegtran');
const imageminPngquant = require('imagemin-pngquant');

(async () => {
    const files = await imagemin(['images/*.{jpg,png}'], {
        destination: 'build/images',
        plugins: [
            imageminJpegtran(),
            imageminPngquant({
                quality: [0.6, 0.8]
            })
        ]
    });

    console.log(files);
    //=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
})();

API

imagemin(input, options?)

Returns Promise<object[]>in the format {data: Buffer, sourcePath: string, destinationPath: string}.

input

Type: string[]

File paths or glob patterns.

options

Type: object

destination

Type: string

Set the destination folder to where your files will be written. If no destination is specified, no files will be written.

plugins

Type: Array

Pluginsto use.

glob

Type: booleanDefault: true

Enable globbing when matching file paths.

imagemin.buffer(buffer, options?)

Returns Promise<Buffer>.

buffer

Type: Buffer

Buffer to optimize.

options

Type: object

plugins

Type: Array

Pluginsto use.

Related


上一篇:hem
下一篇:css-condense
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部