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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcpcn/mcp-image-crop

v1.1.2

Published

MCP server for image cropping with multiple modes and smart upscaling

Readme

图片裁剪工具 (Image Crop MCP)

一个功能强大的图片裁剪 MCP 服务器,支持多种裁剪策略和智能放大功能。

✨ 主要特性

1. 多种裁剪模式

  • 相对裁剪 (Relative Trim) - 推荐使用

    • 通过指定 top/bottom/left/right 参数移除边缘
    • 支持像素值或百分比(如 100'10%'
    • 示例:{top: 100, bottom: 50} 从顶部移除 100px,底部移除 50px
  • 居中裁剪 (Center Crop)

    • 指定目标尺寸,从图片中心裁剪
    • 格式:"800x600""800"(高度自动计算)
  • 手动裁剪 (Manual Crop)

    • 指定起始坐标和尺寸
    • 格式:position: "100,50" + size: "800x600"

2. 🚀 智能放大功能(新增)

问题场景

  • 原图尺寸:330x330
  • 目标裁剪:400x400
  • 传统工具:❌ 失败(目标尺寸超过原图)

智能解决方案

  • ✅ 自动检测目标尺寸是否超过原图
  • ✅ 先将图片放大到足够大小(使用高质量 lanczos3 算法)
  • ✅ 然后执行裁剪操作
  • ✅ 完美支持"放大裁剪"场景

示例

// 将 330x330 的图片裁剪为 400x400
{
  inputPath: ["image_330x330.jpg"],
  outputPath: "output.jpg",
  size: "400x400",
  mode: "center"
}
// 结果:图片先放大到 400x400,然后居中裁剪

3. 批量处理

  • 支持一次处理多张图片
  • 自动生成带编号的输出文件名
  • 独立处理每张图片,失败不影响其他图片

📋 使用示例

示例 1:相对裁剪(移除边缘)

{
  "inputPath": ["photo.jpg"],
  "outputPath": "cropped.jpg",
  "top": 100,
  "bottom": 50,
  "left": "10%",
  "right": "10%"
}

示例 2:居中裁剪(支持放大)

{
  "inputPath": ["small_image.jpg"],
  "outputPath": "avatar.jpg",
  "size": "400x400",
  "mode": "center"
}

示例 3:手动裁剪

{
  "inputPath": ["photo.jpg"],
  "outputPath": "cropped.jpg",
  "size": "800x600",
  "mode": "manual",
  "position": "100,50"
}

示例 4:批量处理

{
  "inputPath": ["img1.jpg", "img2.jpg", "img3.jpg"],
  "outputPath": "output.jpg",
  "size": "1920x1080",
  "mode": "center"
}

输出:output_cropped_1_timestamp.jpg, output_cropped_2_timestamp.jpg, ...

🔧 参数说明

| 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | inputPath | string[] | ✅ | 输入图片路径列表 | | outputPath | string | ✅ | 输出路径(批量处理时自动添加编号) | | size | string | ⚠️ | 目标尺寸,格式 "宽x高" 或 "宽" | | mode | string | ❌ | 裁剪模式:center/manual/trim(默认 center) | | position | string | ⚠️ | 手动模式的起始坐标 "x,y" | | top | number/string | ❌ | 从顶部移除的像素或百分比 | | bottom | number/string | ❌ | 从底部移除的像素或百分比 | | left | number/string | ❌ | 从左侧移除的像素或百分比 | | right | number/string | ❌ | 从右侧移除的像素或百分比 | | quality | number | ❌ | 输出质量 1-100(默认 90) |

⚠️ 表示在特定模式下必填

🎯 优化亮点

  1. 智能放大:自动处理目标尺寸大于原图的情况
  2. 高质量算法:使用 lanczos3 插值算法保证放大质量
  3. 灵活的输入:支持像素值和百分比混合使用
  4. 批量处理:一次处理多张图片,提高效率
  5. 错误隔离:单张图片失败不影响其他图片处理

📦 安装和使用

# 安装依赖
npm install

# 构建
npm run build

# 运行
npm start

🔍 调试模式

设置环境变量 DEBUG=1 启用详细日志:

DEBUG=1 npm start

📝 更新日志

v1.1.0 (最新)

  • ✨ 新增智能放大功能,支持目标尺寸大于原图的裁剪
  • 🎨 使用 lanczos3 高质量插值算法
  • 📝 更新工具描述,添加智能放大说明

v1.0.0

  • 🎉 初始版本
  • 支持三种裁剪模式
  • 支持批量处理
  • 支持百分比和像素值