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

sharp-image

v1.0.3

Published

一个简单的 Node.js 图片压缩工具,支持 JPG、PNG、WebP 格式。

Readme

📦 sharp-image

一个简单好用的 Node.js 图片压缩 CLI 工具,支持压缩 JPG、PNG、WebP 格式图片,支持递归处理文件夹、设置压缩质量,并自动跳过输出目录,避免重复压缩。压缩任务结束后输出压缩统计,压缩效果一目了然。


✨ 功能特色

  • ✅ 支持压缩常见格式:.jpg, .jpeg, .png, .webp
  • ✅ 支持压缩单个图片或整个目录(包括子目录)
  • ✅ 支持文件类型过滤(也可选择 all,压缩所有支持的类型)
  • ✅ 支持设置压缩质量(默认 80)
  • ✅ 自动跳过输出目录(compressed/),避免重复压缩
  • ✅ 命令行易用,适合开发者集成在构建流程或工具链中

📦 安装方式

👉 全局安装(推荐)

npm install -g sharp-image

👉 本地开发安装

git clone https://github.com/Moveharder/sharp-image.git
cd sharp-image
npm install
npm link

🧪 使用示例

压缩整个文件夹下所有支持格式的图片:

sharp-image -i ./images

只压缩 JPG 图片,压缩质量设置为 70:

sharp-image -i ./images -t jpg -q 70

压缩单个图片并自定义输出目录:

sharp-image -i ./photo/test.png -o ./output

🧩 命令参数说明

| 参数 | 说明 | 示例 | | --------------- | ------------------------------------------------------- | ----------- | | -i, --input | 必选,图片文件或文件夹路径 | ./images | | -t, --type | 过滤文件类型,支持:jpg, png, webp, all(默认) | -t jpg | | -q, --quality | 压缩质量(1~100,默认 80) | -q 75 | | -o, --output | 输出目录(默认是 input/compressed) | -o ./dist | | -h, --help | 显示帮助信息 | -h |


📁 目录结构示例

images/
├── a.jpg
├── b.png
└── sub/
    └── c.webp

压缩后:
images/compressed/
├── a.jpg
├── b.png
└── sub/
    └── c.webp

⚙️ 环境要求

  • Node.js >= 18.17.0
  • 支持 Mac(Intel/ARM)、Linux、Windows

如果你遇到 sharp 安装失败,请参考官方文档:
👉 https://sharp.pixelplumbing.com/install


📜 获取安装包

sharp-image

🔧 更新日志

  • 2015.11.11 v1.0.3 优化输出目录路径生成逻辑,增加安全检查