6.0.2 • Published 6 years ago

image-2-min v6.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

image-2-min

Image minifier that respects folder structure.. :)

Build Status Dependency Status DevDependency Status Npm downloads Npm Version Git tag Github issues License

Install

$ npm install --save image-2-min

Usage

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

imagemin(['images/*.{jpg,png}'], 'build/images', {
	plugins: [
		imageminJpegtran()(),
		imageminPngquant({quality: '65-80'})
	]
}).then(files => {
	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: array

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

plugins

Type: array

Array of plugins to use.

cwd

Type: string

The working directoy for image lookups.

imagemin.buffer(buffer, options)

Returns a promise for a buffer.

buffer

Type: buffer

The buffer to optimize.

cwd

Type: string

The working directoy for image lookups.

Related

License

MIT © imagemin