Skip to main content
Glama

get_image_info

Extract image metadata and technical details from files or data inputs to analyze format, dimensions, and properties for informed processing decisions.

Instructions

获取图片文件信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_pathNo图片文件路径(与image_data二选一)
image_dataNo图片数据(Buffer或base64字符串,与image_path二选一)

Implementation Reference

  • src/index.ts:173-189 (registration)
    Registration of the 'get_image_info' tool in the ListTools handler, including its name, description, and input schema.
    {
      name: 'get_image_info',
      description: '获取图片文件信息',
      inputSchema: {
        type: 'object',
        properties: {
          image_path: {
            type: 'string',
            description: '图片文件路径(与image_data二选一)'
          },
          image_data: {
            type: 'string',
            description: '图片数据(Buffer或base64字符串,与image_path二选一)'
          }
        }
      }
    },
  • MCP handler for 'get_image_info' tool in the CallToolRequestHandler switch statement. It calls converter.getImageInfo and formats the response text.
    case 'get_image_info': {
      const { image_path, image_data } = args as { image_path?: string; image_data?: string };
      const info = await this.converter.getImageInfo(image_path, image_data);
      const source = image_path ? `文件路径:${image_path}` : '上传文件';
      return {
        content: [
          {
            type: 'text',
            text: `图片信息:\n${source}\n格式:${info.format}\n尺寸:${info.width}x${info.height}\n文件大小:${info.size} bytes\n颜色通道:${info.channels}\n颜色空间:${info.space || '未知'}`
          }
        ]
      };
    }
  • ImageInfo interface defining the structure of image information returned by getImageInfo.
    export interface ImageInfo {
      format: string;
      width: number;
      height: number;
      channels: number;
      size: number;
      space?: string;
    }
  • Core implementation of getImageInfo in ImageConverter class using Sharp to extract metadata from image file or buffer.
    async getImageInfo(imagePath?: string, imageData?: Buffer | string): Promise<ImageInfo> {
      try {
        let buffer: Buffer;
        let size: number;
    
        if (imageData) {
          if (typeof imageData === 'string') {
            const base64Data = imageData.includes(',') ? imageData.split(',')[1] : imageData;
            buffer = Buffer.from(base64Data, 'base64');
          } else {
            buffer = imageData;
          }
          size = buffer.length;
        } else if (imagePath) {
          await fs.access(imagePath);
          const stats = await fs.stat(imagePath);
          buffer = await fs.readFile(imagePath);
          size = stats.size;
        } else {
          throw new Error('必须提供imagePath或imageData参数');
        }
    
        const metadata = await sharp(buffer).metadata();
    
        return {
          format: metadata.format || 'unknown',
          width: metadata.width || 0,
          height: metadata.height || 0,
          channels: metadata.channels || 0,
          size: size,
          space: metadata.space
        };
      } catch (error) {
        throw new Error(`无法获取图片信息: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states what the tool does ('获取图片文件信息') without mentioning any behavioral traits such as performance characteristics, error handling, or what happens with invalid inputs. This leaves significant gaps in understanding how the tool behaves in practice.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese ('获取图片文件信息') that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what information is returned (e.g., dimensions, format, metadata), how errors are handled, or any limitations. For a tool with two parameters and no structured output documentation, more context is needed to be fully useful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with clear descriptions for both parameters ('image_path' and 'image_data') and their mutual exclusivity. The description adds no additional meaning beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取图片文件信息' (Get image file information) states a clear verb ('获取' - get) and resource ('图片文件信息' - image file information), but it's somewhat vague about what specific information is retrieved (dimensions, format, metadata, etc.). It doesn't differentiate from siblings like 'list_supported_formats' which also provides information, though about different aspects.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context, or comparisons to sibling tools like 'batch_convert_images' or 'convert_image'. Users must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickstar-2002/image-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server