Observed since 20 Oct, 18:11 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Add your description here
基于 Model Context Protocol (MCP) 的图片压缩服务,使用 Python 和 uv 构建。提供多种图片压缩算法和格式转换功能,支持批量处理。
输入格式:PNG, JPG, JPEG, BMP, TIFF, GIF 输出格式:WebP, AVIF
如果还没有安装 uv,请根据您的操作系统选择以下方式之一:
方法一:使用官方安装脚本(推荐)
curl -LsSf https://astral.sh/uv/install.sh | sh
安装完成后,需要将 uv 添加到 PATH(如果提示):
# 添加到 ~/.zshrc 或 ~/.bash_profile
export PATH="$HOME/.cargo/bin:$PATH"
方法二:使用 Homebrew
brew install uv
方法一:使用官方安装脚本(推荐)
curl -LsSf https://astral.sh/uv/install.sh | sh
如果系统没有 curl,可以使用 wget:
wget -qO- https://astral.sh/uv/install.sh | sh
安装完成后,需要将 uv 添加到 PATH(如果提示):
# 添加到 ~/.bashrc 或 ~/.zshrc
export PATH="$HOME/.cargo/bin:$PATH"
方法二:使用 pipx 或 pip
# 使用 pipx(推荐)
pipx install uv
# 或使用 pip
pip install uv
方法一:使用 PowerShell 脚本(推荐)
打开 PowerShell(建议以管理员身份运行),执行:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
如果遇到执行策略错误,需要先运行:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
方法二:使用 pipx 或 pip
# 使用 pipx(推荐)
pipx install uv
# 或使用 pip
pip install uv
安装完成后,可以通过以下命令验证:
uv --version
如果显示版本号,说明安装成功。
在 Claude Desktop 或其他 MCP 客户端中配置:
{
"mcpServers": {
"acg-frontend-mcp": {
"command": "uvx",
"args": ["acg-frontend-mcp"]
}
}
}
uvx 会自动下载并运行最新版本的包,无需手动安装或配置路径。
本项目提供了一个 MCP 工具 compress_images,可以通过 MCP 协议调用。
批量压缩图片,支持多种压缩类型和格式转换。
参数说明:
| 参数 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
input_dir | string | 是 | - | 包含图片文件的输入目录路径 |
output_dir | string | 是 | - | 压缩后图片的输出目录路径 |
compression_type | string | 是 | - | 压缩类型(见下表) |
max_size_kb | integer | 否 | 50 | 目标最大文件大小(KB) |
quality | integer | 否 | 80 | WebP/AVIF 质量 (0-100) |
keep_original_size | boolean | 否 | false | 是否保持原始尺寸 |
optimize | boolean | 否 | true | 是否启用优化 |
method | integer | 否 | 6 | 压缩方法 (0-6,6为最强压缩) |
压缩类型:
| 类型 | 说明 | 适用场景 |
|---|---|---|
image_lossless | 通用图片无损压缩 | 图标、UI、插画、需要保持透明度的图片 |
image_extreme | 通用图片极度压缩(有损) | 追求最小体积,允许一定质量损失 |
image_force_lossless | 通用图片强制无损压缩 | 忽略大小限制的无损压缩 |
image_ultra | 通用图片超强压缩 | 智能选择有损/无损(quality>=95 时无损) |
webp | 转换为 WebP 格式 | 标准 WebP 格式转换 |
avif | 转换为 AVIF 格式 | 追求更高压缩比(编码较慢) |
在支持 MCP 的客户端中,可以这样使用:
请帮我压缩 /Users/xxx/images 目录下的所有图片,
使用无损压缩,输出到 /Users/xxx/compressed 目录
客户端会自动调用 compress_images 工具:
{
"input_dir": "/Users/xxx/images",
"output_dir": "/Users/xxx/compressed",
"compression_type": "image_lossless",
"max_size_kb": 50
}
max_size_kb 仅用于结果提示,不会降低画质或缩小分辨率max_size_kb 或降至最低质量image_lossless 或 image_force_losslessimage_extreme 或 image_ultraimage_extreme,设置合适的 max_size_kbavif(注意编码速度和兼容性)quality 参数对 AVIF 不生效MIT License
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.4 | 2 Nov 2025 | 3 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 18:11 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:7affac1b6e3aea8bd138d94cc73e4ba2cd39d9d64850a2b00dd61fbbacb533a4