npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

kuma-imagemin

v0.5.2

Published

一个整合了mozjpeg和pngquant的图片压缩工具

Downloads

5

Readme

kuma-imagemin

License: GPL v3

一个基于mozjpegpngquant压缩算法进行图片压缩的小工具。它通过将两个压缩算法的代码由C编译成Javascript,可以在浏览器Node环境下运行,同时降低了依赖安装的难度。

jpeg 压缩方法基于mozjpeg-js

png 压缩方法基于pngquantjs

安装

npm install kuma-imagemin

使用

命令行调用

# 压缩文件
npx kuma-imagemin min <文件(夹)路径>

# 查看帮助
# 更多操作请自行看帮助信息
npx kuma-imagemin -h

方法调用

const fs = require('fs-extra');
const {
  minPng,
  minJpg,
  minDir,
  clearOrigin,
  clearLog,
  log,
  isMin,
  resetByOrigin,
} = require('kuma-imagemin');

// 压缩png
const pngRes = minPng(fs.readFileSync('test.png'), {
  quality: '60-80',
});
// 压缩后的png数据,格式为 Uint8Array
console.log(pngRes.data);
// 压缩率
console.log(pngRes.ratio);

// 压缩jpg
const jpgRes = minJpg(fs.readFileSync('test.png'), {
  quality: 0.6,
});
// 压缩后的jpg数据,格式为 Uint8Array
console.log(jpgRes.data);
// 压缩率
console.log(jpgRes.ratio);

// 压缩指定文件夹
minDir('img', {
  // 是否生成备份源文件
  backup: true,
  // 是否强制压缩文件
  force: false,
});

// 删除指定文件夹内的备份源文件
clearOrigin('img');

// 删除插件压缩日志(记录所有被压缩过文件的md5,删除后所有文件都当成未被压缩)
clearLog();

// 添加压缩日志记录
log({
  'img/test.png': '38d034676322c1c6350190ccfc3eca58' // md5
});

// 判断一个文件是否已经被压缩(依赖日志记录)
isMin('img/test.png');

// 用备份源文件还原压缩后的文件(需要在压缩时保留备份源文件)
resetByOrigin('img');

License

由于mozjpeg-js使用BSD 3协议,pngquantjs使用GPL v3协议。故kuma-imagemin只能使用GPL v3协议。