get_image_info
Extract image metadata including dimensions and format from a specified file path to support feedback collection with visual content analysis.
Instructions
获取指定路径图片的信息(尺寸、格式等)
Args:
image_path: 图片文件路径
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_path | Yes |
Implementation Reference
- src/mcp_feedforward/server.py:481-512 (handler)The handler function for the 'get_image_info' MCP tool. It uses PIL to open the image at the given path, extracts metadata like format, mode, size, dimensions, and file size, and returns a formatted string with the information. Registered via @mcp.tool() decorator.@mcp.tool() def get_image_info(image_path: str) -> str: """ 获取指定路径图片的信息(尺寸、格式等) Args: image_path: 图片文件路径 """ try: image_path = Path(image_path) if not image_path.exists(): return f"图片文件不存在: {image_path}" with Image.open(image_path) as img: info = { "path": str(image_path), "format": img.format, "mode": img.mode, "size": img.size, "width": img.width, "height": img.height, } # 尝试获取文件大小 file_size = image_path.stat().st_size info["file_size_bytes"] = file_size info["file_size_mb"] = round(file_size / (1024 * 1024), 2) return f"图片信息: {info}" except Exception as e: return f"获取图片信息失败: {str(e)}"
- src/mcp_feedforward/server.py:481-481 (registration)The @mcp.tool() decorator registers the get_image_info function as an MCP tool.@mcp.tool()
- Input schema defined by function signature (image_path: str) and docstring Args section.def get_image_info(image_path: str) -> str: """ 获取指定路径图片的信息(尺寸、格式等) Args: image_path: 图片文件路径 """