Skip to content

stcjs/stc-imagemin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stc-imagemin

Minify PNG, JPEG and GIF images for stc

Install

npm install stc-imagemin --save

How to use

// stc.config.js

stc.workflow({
  imagemin: {plugin: imagemin}
})

默认 png 使用 pngquant 优化,jpg 使用 jpegtran 优化,gif 使用 gifsicle 优化。你也可以使用下面其他的优化工具:

其他优化工具

png

var optipng = require('optipng-bin');

stc.workflow({
  imagemin: {plugin: imagemin, options: {
    png: {adapter: optipng, args: ['-out', 'outfile', 'infile']}
  }}
})
var zopflipng = require('zopflipng-bin');

stc.workflow({
  imagemin: {plugin: imagemin, options: {
    png: {adapter: zopflipng, args: ['-m', '--lossy_8bit', 'infile', 'outfile']}
  }}
})
var pngcrush = require('pngcrush-bin');

stc.workflow({
  imagemin: {plugin: imagemin, options: {
    png: {adapter: pngcrush, args: ['-reduce', '-brute', 'infile', 'outfile']}
  }}
})
var pngout = require('pngout-bin');

stc.workflow({
  imagemin: {plugin: imagemin, options: {
    png: {adapter: pngout, args: ['infile', 'outfile', '-s0', '-k0', '-f0']}
  }}
})

jpg

var mozjpeg = require('mozjpeg-bin');

stc.workflow({
  imagemin: {plugin: imagemin, options: {
    png: {adapter: mozjpeg, args: ['-outfile', 'outfile', 'infile']}
  }}
})
var recompress = require('recompress-bin');

stc.workflow({
  imagemin: {plugin: imagemin, options: {
    png: {adapter: recompress, args: ['--quality high', '--min 60', 'infile', 'outfile']}
  }}
})

About

Minify PNG, JPEG and GIF images for stc

Resources

License

Stars

Watchers

Forks

Packages

No packages published