1.0.0 • Published 5 years ago

imagemin-compress v1.0.0

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

Explain

Image compress generator, Reduce package volume. compliant:jpg、jpeg、png、svg、gif

Install

npm i imagemin-compress -D

Usage

Commander

Using the command line to compress images. The files dest value is the same, the compressed picture will overwrite the original picture, Will not retain the original image, Will be applied to the build to the directory。

imagemin-compress -f[--files] -d[--dest] -c[--config]

Npm scripts

Using package.json:

{
  "scripts": {
    ...,
    "imagemin": "imagemin-compress -f ./images -d ./imagesmin"
  }
}
paramtypeexplain
filesstringImage catalog name
deststringDirectory name of output, defalut: files value
configobjectConfiguration file, default: imagemin.config.js, return "object"

API

The way used in script files, Return Promise class. Specific reference to the following script examples:

const imageminCompress = reqiure('imagemin-compress')

imageminCompress(options).then(_ => {})

or:

const compile = async options => await imageminCompress(options)

Reference

Options params: Extended:

keytypevalue explain
filesstring/pattern/arrayglob type path value
deststringDirectory name of output, defalut: "files" value
verbosebooleanOutput compress inforamtion, default: true
qualityarrayPicture compression mass range value, default: 0.6, 0.8

Specific instructions can be referred to link: imagemin