关于 Imagician
Imagician 是一个用于图像编辑的 MCP 服务,支持缩放、格式转换、裁剪、压缩等操作。面向需要在 AI 助手中直接处理图片的用户,可通过 npm 安装并接入 Claude Code、Cursor 或 Claude Desktop。
主要功能
- 01缩放图片,支持多种适配方式
- 02在 JPEG、PNG、WebP、AVIF 之间转换格式
- 03裁剪指定区域并调节压缩质量
- 04旋转与水平、垂直翻转
- 05提取图片元数据信息
- 06一次生成多个尺寸的批量输出
适用场景
- 01为网页生成响应式图片的多种尺寸
- 02将图片批量转换为 WebP 或 AVIF 格式
- 03压缩图片以减小文件体积
MCP 相关
该项目是一个 MCP 服务,向 MCP 客户端暴露 resize_image、convert_format、crop_image、compress_image、rotate_image、flip_image、get_image_info 和 batch_resize 等工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
8收录的工具列表 · 更新于 3 周前
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| inputPath | string | 是 | 输入图像的路径 |
| outputPath | string | 是 | 保存调整尺寸后图像的路径 |
| width | number | 否 | 目标宽度(像素) |
| height | number | 否 | 目标高度(像素) |
| fit | enum | 否 | 图像适应目标尺寸的调整方式cover | contain | fill | inside | outside |
| preserveAspectRatio | boolean | 否 | 保持原始宽高比 |
详细介绍
Imagician - MCP 图像编辑器
一个 Model Context Protocol(MCP)服务,可执行全面的图像编辑操作,包括调整大小、格式转换、裁剪、压缩等。
功能
- 调整大小:使用多种适配选项更改图像尺寸
- 格式转换:在 JPEG、PNG、WebP 和 AVIF 之间转换
- 裁剪:从图像中提取特定区域
- 压缩:通过质量控制减小文件大小
- 旋转:按任意角度旋转图像
- 翻转:水平或垂直镜像图像
- 批量处理:从单张图像生成多种尺寸
- 元数据:提取图像信息和属性
安装
从 npm 安装
npm install -g @flowy11/imagician
从源代码安装
git clone https://github.com/flowy11/imagician.git
cd imagician
npm install
npm run build
在 Claude Code 中使用
添加到 Claude Code 配置(~/.config/claude/config/settings/mcp-servers.json):
{
"imagician": {
"command": "npx",
"args": ["-y", "@flowy11/imagician"]
}
}
在 Cursor 中使用
添加到 Cursor 配置(~/.cursor/mcp_settings.json):
{
"mcpServers": {
"imagician": {
"command": "npx",
"args": ["-y", "@flowy11/imagician"]
}
}
}
在 Claude Desktop 中使用
添加到 Claude Desktop 配置(~/Library/Application Support/Claude/claude_desktop_config.json):
使用 npx 快速设置(推荐):
{
"mcpServers": {
"imagician": {
"command": "npx",
"args": ["-y", "@flowy11/imagician"]
}
}
}
如果通过 npm 全局安装:
{
"mcpServers": {
"imagician": {
"command": "imagician"
}
}
}
如果从源代码安装:
{
"mcpServers": {
"imagician": {
"command": "node",
"args": ["/path/to/imagician/dist/index.js"]
}
}
}
可用工具
resize_image
将图像调整为指定尺寸,并提供多种适配选项。
Parameters:
- inputPath: Path to input image
- outputPath: Path to save resized image
- width: Target width in pixels (optional)
- height: Target height in pixels (optional)
- fit: How to resize (cover, contain, fill, inside, outside)
- preserveAspectRatio: Maintain aspect ratio (default: true)
convert_format
在不同图像格式之间转换,并可控制质量。
Parameters:
- inputPath: Path to input image
- outputPath: Path to save converted image
- format: Target format (jpeg, png, webp, avif)
- quality: Quality for lossy formats (1-100, default: 80)
crop_image
从图像中提取特定区域。
Parameters:
- inputPath: Path to input image
- outputPath: Path to save cropped image
- left: Left offset in pixels
- top: Top offset in pixels
- width: Width of crop area
- height: Height of crop area
compress_image
通过质量设置减小图像文件大小。
Parameters:
- inputPath: Path to input image
- outputPath: Path to save compressed image
- quality: Compression quality (1-100, default: 80)
- progressive: Use progressive encoding for JPEG (default: true)
rotate_image
按任意角度旋转图像。
Parameters:
- inputPath: Path to input image
- outputPath: Path to save rotated image
- angle: Rotation angle in degrees (positive = clockwise)
- background: Background color for exposed areas (default: #000000)
flip_image
水平或垂直镜像图像。
Parameters:
- inputPath: Path to input image
- outputPath: Path to save flipped image
- direction: Flip direction (horizontal, vertical, both)
get_image_info
提取图像的元数据和相关信息。
Parameters:
- inputPath: Path to image file
Returns: format, dimensions, color space, file size, etc.
batch_resize
从一张图像生成多种尺寸(非常适合响应式图像)。
Parameters:
- inputPath: Path to input image
- outputDir: Directory to save resized images
- sizes: Array of {width, height?, suffix}
- format: Output format for all sizes (optional)
在 Claude 中的使用示例
"Please resize image.jpg to 800x600 pixels"
"Convert photo.png to WebP format with 90% quality"
"Crop avatar.jpg starting at (100, 100) with 200x200 size"
"Generate thumbnail sizes: 150px, 300px, and 600px wide"
开发
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run in development mode
npm run dev
许可证
MIT
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。