返回市场
魔术师

魔术师

作者:flowy1117 星标更新:2025-11-14

项目介绍

Imagician - MCP 图像编辑器

npm 版本

一个用于全面图像编辑操作的 Model Context Protocol (MCP) 服务器,包括调整大小、格式转换、裁剪、压缩等。

<a href="https://glama.ai/mcp/servers/@flowy11/imagician"> <img width="380" height="200" src="https://gips0.baidu.com/it/u=3929151576,3597198644&fm=3081&app=31&f=PNG?w=760&h=400" alt="Imagician MCP 服务器" /> </a>

功能

  • 调整大小:使用各种适配选项更改图像尺寸
  • 格式转换:在 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):

快速设置(推荐):

{
  "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

将图像调整到指定尺寸,并提供多种适配选项。

参数:
- inputPath: 输入图像路径
- outputPath: 调整大小后保存图像的路径
- width: 目标宽度(像素,可选)
- height: 目标高度(像素,可选)
- fit: 如何调整大小(cover, contain, fill, inside, outside)
- preserveAspectRatio: 是否保持宽高比(默认: true)

convert_format

在图像格式之间转换,并进行质量控制。

参数:
- inputPath: 输入图像路径
- outputPath: 转换后保存图像的路径
- format: 目标格式(jpeg, png, webp, avif)
- quality: 有损格式的质量(1-100,默认: 80)

crop_image

从图像中提取特定区域。

参数:
- inputPath: 输入图像路径
- outputPath: 裁剪后保存图像的路径
- left: 左偏移量(像素)
- top: 上偏移量(像素)
- width: 裁剪区域宽度
- height: 裁剪区域高度

compress_image

通过质量设置减少图像文件大小。

参数:
- inputPath: 输入图像路径
- outputPath: 压缩后保存图像的路径
- quality: 压缩质量(1-100,默认: 80)
- progressive: 对于 JPEG 是否使用渐进编码(默认: true)

rotate_image

以任意角度旋转图像。

参数:
- inputPath: 输入图像路径
- outputPath: 旋转后保存图像的路径
- angle: 旋转角度(度数,正值表示顺时针)
- background: 显示区域的背景颜色(默认: #000000)

flip_image

水平或垂直镜像图像。

参数:
- inputPath: 输入图像路径
- outputPath: 镜像后保存图像的路径
- direction: 镜像方向(horizontal, vertical, both)

get_image_info

提取关于图像的元数据和信息。

参数:
- inputPath: 图像文件路径

返回:格式、尺寸、色彩空间、文件大小等。

batch_resize

从一张图像生成多个尺寸(适用于响应式图像)。

参数:
- inputPath: 输入图像路径
- outputDir: 保存调整大小后的图像目录
- sizes: 包含 {width, height?, suffix} 的数组
- format: 所有尺寸的输出格式(可选)

在 Claude 中的示例用法

"请将 image.jpg 调整为 800x600 像素"
"将 photo.png 转换为 WebP 格式,质量为 90%"
"从 (100, 100) 开始裁剪 avatar.jpg,尺寸为 200x200"
"生成缩略图尺寸:150px、300px 和 600px 宽"

开发

# 安装依赖
npm install

# 构建 TypeScript
npm run build

# 开发模式运行
npm run dev

许可证

MIT