Process Images From Your Coding Session — Smart Crop, Convert, Compress via MCP
Process Images From Your Coding Session — Smart Crop, Convert, Compress via MCP
在编码过程中处理图像——通过 MCP 实现智能裁剪、转换与压缩
Image Processing Shouldn’t Break Your Flow. Image processing tasks are small but they interrupt everything. A designer sends over a photo that’s the wrong dimensions. A client’s logo is a 4MB PNG that needs to be a 40KB WebP. A product photo needs smart-cropping for a thumbnail but the subject is off-center. None of these take more than ten seconds to describe — but each one takes you out of your editor, into a terminal, into an image app, or into a back-and-forth with the designer. With MCP, your AI assistant handles it directly. The Iteration Layer’s Image Transformation API ships as an MCP server — connect it once, and Claude Code or Cursor can resize, smart crop, convert, compress, and chain up to 30 operations together from a chat prompt. You describe what you need, the assistant builds the operation sequence, and you get the result without leaving your session.
图像处理不应打断你的工作流。图像处理任务虽小,却往往会打断一切。设计师发来一张尺寸错误的图片;客户的 Logo 是一个 4MB 的 PNG,需要转成 40KB 的 WebP;产品照片需要智能裁剪成缩略图,但主体却不在中心。描述这些需求只需不到十秒,但每一项都需要你离开编辑器,进入终端、打开图像应用,或者与设计师反复沟通。有了 MCP,你的 AI 助手可以直接处理这些任务。Iteration Layer 的图像转换 API 以 MCP 服务器的形式提供——只需连接一次,Claude Code 或 Cursor 就能通过聊天提示词实现调整大小、智能裁剪、转换、压缩,并串联多达 30 个操作。你只需描述需求,助手会自动构建操作序列,让你无需离开当前会话即可获得结果。
What MCP Is. Model Context Protocol is an open standard that lets AI assistants discover and call external tools. Think of it as a plugin system for AI — you connect a service, and the assistant can use it when relevant. When you connect the Image Transformation API as an MCP server, your assistant gains the ability to: Resize images to specific dimensions, Crop images (including AI-powered smart crop), Convert between formats (PNG, JPEG, WebP, AVIF), Chain up to 30 operations in a single request, Apply filters, adjust colors, and optimize file sizes. All from a natural language prompt.
什么是 MCP。Model Context Protocol(模型上下文协议)是一项开放标准,允许 AI 助手发现并调用外部工具。你可以将其视为 AI 的插件系统——连接一项服务后,助手便能在需要时使用它。当你将图像转换 API 作为 MCP 服务器连接后,你的助手将获得以下能力:将图像调整为特定尺寸、裁剪图像(包括 AI 驱动的智能裁剪)、在不同格式间转换(PNG、JPEG、WebP、AVIF)、在单个请求中串联多达 30 个操作、应用滤镜、调整颜色以及优化文件大小。所有这些都只需通过自然语言提示词即可完成。
Setting Up in Claude Code. Claude Code supports MCP servers natively. Add the Iteration Layer server with a single command: claude mcp add iterationlayer --transport http https://api.iterationlayer.com/mcp. The first time you use an Iteration Layer tool, a browser window opens for OAuth authentication. Log in, authorize access, and you’re connected. No API keys to manage. To verify the server is available, start a conversation and ask Claude Code what MCP tools it has access to. You should see transform_image listed among the available tools.
在 Claude Code 中设置。Claude Code 原生支持 MCP 服务器。使用单条命令即可添加 Iteration Layer 服务器:claude mcp add iterationlayer --transport http https://api.iterationlayer.com/mcp。首次使用 Iteration Layer 工具时,浏览器会弹出窗口进行 OAuth 认证。登录并授权访问后,连接即告完成,无需管理 API 密钥。要验证服务器是否可用,请开启对话并询问 Claude Code 它拥有哪些 MCP 工具的访问权限。你应该能在可用工具列表中看到 transform_image。
Setting Up in Cursor. Add to your .cursor/mcp.json:
{
"mcpServers": {
"iterationlayer": {
"type": "http",
"url": "https://api.iterationlayer.com/mcp"
}
}
}
Save and restart. The Image Transformation tool is now available in your Cursor AI conversations. Authentication works the same way — OAuth in the browser on first use.
在 Cursor 中设置。将其添加到你的 .cursor/mcp.json 文件中:
(代码块同上)
保存并重启。现在,图像转换工具已可在你的 Cursor AI 对话中使用。认证方式相同——首次使用时通过浏览器进行 OAuth 授权。
Using It Conversationally. The strength of MCP is that you describe intent, not API parameters. The assistant translates natural language into the right combination of operations. Resize for a landing page hero: “Resize this to 1200x630, convert to WebP at 85% quality.” The assistant translates that into two operations — a resize with cover fit and a convert to WebP with quality 85 — and returns the processed image. Smart crop a product photo: “Smart crop this product photo to 400x400 — keep the product centered.” The assistant calls the smart_crop operation, which uses AI object detection to find the main subject before cropping. No coordinate math on your part.
通过对话使用。MCP 的优势在于你描述的是意图,而非 API 参数。助手会将自然语言转换为正确的操作组合。例如,为落地页首图调整大小:“将此图调整为 1200x630,转换为 85% 质量的 WebP。”助手会将其转换为两个操作——以“覆盖(cover)”模式调整大小,并转换为质量为 85 的 WebP,随后返回处理后的图像。智能裁剪产品照片:“将此产品照片智能裁剪为 400x400,保持产品居中。”助手会调用 smart_crop 操作,利用 AI 对象检测在裁剪前定位主体。你无需进行任何坐标计算。
24 Operations, One Tool. The Image Transformation API supports 24 operations that chain sequentially. Through MCP, your assistant can combine them in a single request: Geometry (resize, crop, smart_crop, extend, trim, rotate, flip, flop), Color (modulate, tint, grayscale, invert_colors, auto_contrast, gamma), Quality (blur, sharpen, denoise, threshold, opacity), Output (convert, compress_to_size, upscale), Transparency (remove_transparency). Each operation’s output feeds into the next, so “resize then convert then compress” is one API call with three operations. The 30-operation limit is generous — most real tasks need three to five.
24 种操作,一个工具。图像转换 API 支持 24 种可顺序串联的操作。通过 MCP,你的助手可以在单个请求中组合它们:几何变换(调整大小、裁剪、智能裁剪、扩展、修剪、旋转、翻转)、颜色调整(调节、着色、灰度、反色、自动对比度、伽马)、质量处理(模糊、锐化、降噪、阈值、不透明度)、输出(转换、压缩至指定大小、放大)、透明度(移除透明度)。每个操作的输出都会传递给下一个,因此“调整大小 -> 转换 -> 压缩”只需一次 API 调用即可完成三个操作。30 个操作的上限非常充裕——大多数实际任务只需三到五个操作。
What Happens Under the Hood. When you describe an image transformation in natural language, the assistant doesn’t just forward your text to the API. It constructs a structured API request with the correct operation types, parameters, and ordering. The assistant makes decisions you didn’t specify: it picks cover as the default fit strategy, sets quality to 85, and orders the operations correctly. If you need different defaults, just say so, and the assistant adjusts. The MCP server handles authentication, request formatting, and response parsing. The assistant receives the processed image back and can display it in the conversation.
幕后原理。当你用自然语言描述图像转换时,助手并不仅仅是将文本转发给 API。它会构建一个包含正确操作类型、参数和顺序的结构化 API 请求。助手会替你做出未明确指定的决策:它会选择“覆盖(cover)”作为默认适配策略,将质量设为 85,并正确排列操作顺序。如果你需要不同的默认设置,只需说明即可,助手会进行调整。MCP 服务器负责处理认证、请求格式化和响应解析。助手接收处理后的图像并将其显示在对话中。