node package manager

minify-images

minify-images

Dead simply script to minify images with node utilizing imagemin.

Travis branch Code Climate Coveralls David Dependencies David Dev-Dependencies

Installation

yarn add minify-images --dev

Usage

import minify from 'minify-images'
 
minify.compress({
  src: 'path/to/input/*',
  dest: 'path/to/output',
}).then(files => {
  files.should.exist
}).catch(error => {
  throw error
})

The src option accepts globbing patterns.

API

minify([options])

Returns a promise for an array of output file path strings.

options

Type: Object

An object containing options.

options.src

Type: string

Default: './src/**/*.{jpg|png|svg|jpeg}'

Path the source image files. Can be a file, directory, or any globbing pattern.

options.dest

Type: string

Default: './dist'

The path to place the output files.

options.jpg

Type: Object

Default:

{
  quality: '90',
}

Options passed to mozjpeg.

options.png

Type: Object

Default:

{
  quality: '65-80',
  speed: 4,
}

Options passed to pngquant.

options.svg

Type: Object

Default:

{
  plugins: [{
    removeTitle: true,
    removeDesc: true,
    removeXMLNS: true,
  }],
}

Options passerd to svgo.

Tests

git clone https://github.com/nielse63/minify-images.git
cd minify-images
yarn install
yarn test

License

MIT @ Erik Nielsen