2.0.0 • Published 4 years ago

compress-picture v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

compress-picture

minify PNG, JPEG, GIF, SVG and WEBP images

Global Install

You can install it globally so you can use it everywhere

npm install compress-picture -g

global usage :

compress-picture --input [filePath] --output [outputPath] --extnames [extnames]

example:

default output to folder named compressed

compress-picture --i './images' --o './compressed' --ext '.jpg,.png,.webp,.svg,.gif'

Local Install

In order to use it better, you should install it locally and configure it

npm install compress-picture -D

Usage

For each optimizer you wish to configure, specify the corresponding key in options:

const compressPicture = require('compress-picture')
// console.log(compressPicture)

compressPicture({
  input: './images'
  output: 'compressed',
  extnames: [ '.jpg', '.png', '.svg', '.webp', '.gif' ],
  mozjpeg: {
    progressive: true,
    quality: 65
  },
  // optipng.enabled: false will disable optipng
  optipng: {
    enabled: false,
  },
  pngquant: {
    quality: [0.65, 0.90],
    speed: 4
  },
  gifsicle: {
    interlaced: false,
  },
  // the webp option will enable WEBP
  webp: {
    quality: 75
  }
})

Optional

input

Type: string

Source directory or source file path

output

Type: string Default: compressed

Compress output path

extnames

Type: string|array Default: .png,.jpg,.svg,.webp,.gif


The following optimizers are included, you can click to view their configuration documents:

License

MIT