Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

stfsy/node-image-2-min

 
 

Repository files navigation

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

About

Forked version of imagemin, which preserves folder structure of input files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%