Skip to main content
Glama

resize_image

Resize images to specific dimensions using scale, fit, cover, or thumb methods for web optimization and display requirements.

Instructions

Resize an image file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imagePathYesThe ABSOLUTE path to the image file to resize
outputPathNoThe ABSOLUTE path to save the resized image file
methodNoThe method describes the way your image will be resized.fit
widthYesThe width to resize the image to
heightYesThe height to resize the image to

Implementation Reference

  • Handler function for 'resize_image' tool in TOOL_HANDLERS, which extracts parameters and calls the core resize logic.
    resize_image: async (request) => {
      await handleResizeImageTool(
        request.params.arguments as {
          imagePath: string;
          outputPath?: string;
          width: number;
          height: number;
          method: 'scale' | 'fit' | 'cover' | 'thumb';
        },
      );
      return {
        content: [
          {
            type: 'text',
            text: 'Image resized successfully',
          },
        ],
        metadata: {},
      };
    },
  • Core implementation of image resizing using Tinify API, handling input parameters, resizing, and output path generation.
    async function handleResizeImageTool({
      imagePath,
      outputPath,
      width,
      height,
      method,
    }: {
      imagePath: string;
      outputPath?: string;
      width: number;
      height: number;
      method?: 'scale' | 'fit' | 'cover' | 'thumb';
    }) {
      const source = tinify.fromFile(imagePath);
      const resized = source.resize({
        method: method || 'fit',
        width,
        height,
      });
    
      let dest = outputPath;
      if (!dest) {
        const dir = path.dirname(imagePath);
        const basename = path.basename(imagePath, path.extname(imagePath));
        const ext = path.extname(imagePath).slice(1);
        dest = path.join(dir, `${basename}_${width}x${height}.${ext}`);
      }
      await resized.toFile(dest);
    }
  • Tool definition including name, description, and input schema for 'resize_image'.
    const RESIZE_IMAGE_TOOL: Tool = {
      name: 'resize_image',
      description: 'Resize an image file',
      inputSchema: {
        type: 'object',
        properties: {
          imagePath: {
            type: 'string',
            description: 'The ABSOLUTE path to the image file to resize',
            example: '/Users/user/Downloads/image.jpg',
          },
          outputPath: {
            type: 'string',
            description: 'The ABSOLUTE path to save the resized image file',
            example: '/Users/user/Downloads/image_thumbnail.jpg',
          },
          method: {
            type: 'string',
            description: 'The method describes the way your image will be resized.',
            enum: ['scale', 'fit', 'cover', 'thumb'],
            default: 'fit',
            example: 'fit',
          },
          width: {
            type: 'number',
            description: 'The width to resize the image to',
            example: 1024,
          },
          height: {
            type: 'number',
            description: 'The height to resize the image to',
            example: 1024,
          },
        },
        required: ['imagePath', 'width', 'height'],
      },
    };
  • src/tools.ts:117-117 (registration)
    Registration of the resize_image tool in the exported TOOLS array.
    export const TOOLS = [COMPRESS_LOCAL_IMAGE_TOOL, COMPRESS_REMOTE_IMAGE_TOOL, RESIZE_IMAGE_TOOL];
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. 'Resize an image file' implies a transformation operation but reveals nothing about whether this modifies the original file, creates a new file, what file formats are supported, potential quality loss, or error conditions. This is inadequate for a tool with 5 parameters and no output schema.

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 perfectly concise at just 4 words ('Resize an image file'). It's front-loaded with the core purpose and contains no unnecessary information, making it highly efficient for agent comprehension.

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?

For a tool with 5 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns, what happens to the original file, supported image formats, or any behavioral characteristics. The agent would need to guess about important operational details.

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%, so the schema already fully documents all 5 parameters. The description adds no additional parameter information beyond what's in the schema, which meets the baseline expectation when schema coverage is complete.

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

Purpose4/5

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

The description 'Resize an image file' clearly states the action (resize) and resource (image file), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling tools (compress_local_image, compress_remote_image), which perform compression rather than resizing operations.

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?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of its sibling tools or any other context that would help an agent decide between resizing and compression operations, leaving the agent without usage direction.

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/aiyogg/tinypng-mcp-server'

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