Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

imagemin

6.0.0 • Public • Published

imagemin Build Status Build status

Minify images seamlessly

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}'], 'build/images', {
        plugins: [
            imageminJpegtran(),
            imageminPngquant({quality: '65-80'})
        ]
    });
 
    console.log(files);
    //=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
})();

API

imagemin(input, [output], [options])

Returns Promise<Object[]> in the format {data: Buffer, path: String}.

input

Type: string[]

Files to be optimized. See supported minimatch patterns.

output

Type: string

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

options

Type: Object

plugins

Type: Array

Plugins to use.

imagemin.buffer(buffer, [options])

Returns Promise<Buffer>.

buffer

Type: Buffer

Buffer to optimize.

options

Type: Object

plugins

Type: Array

Plugins to use.

Related

License

MIT © imagemin

install

npm i imagemin

Downloadsweekly downloads

345,583

version

6.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability