Skip to main content
Glama

resize_image

Resize images to specific dimensions with control over width, height, and aspect ratio using the Imagician server's image editing capabilities.

Instructions

Resize an image to specified dimensions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesPath to input image
outputPathYesPath to save resized image
widthNoTarget width in pixels
heightNoTarget height in pixels
fitNoHow the image should be resized to fitcover
preserveAspectRatioNoMaintain original aspect ratio

Implementation Reference

  • The handler function for the 'resize_image' tool. It destructures the input arguments, ensures the output directory exists, creates a Sharp pipeline for the input image, applies resize operation if width or height specified, and saves the result to outputPath. Returns a success message.
    case 'resize_image': {
      const { inputPath, outputPath, width, height, fit = 'cover', preserveAspectRatio = true } = args;
      
      await fs.mkdir(path.dirname(outputPath), { recursive: true });
      
      let pipeline = sharp(inputPath);
      
      if (width || height) {
        pipeline = pipeline.resize({
          width: width || undefined,
          height: height || undefined,
          fit: fit as any,
          withoutEnlargement: preserveAspectRatio
        });
      }
      
      await pipeline.toFile(outputPath);
      
      return {
        content: [
          {
            type: 'text',
            text: `Image resized successfully. Saved to: ${outputPath}`
          }
        ]
      };
    }
  • src/index.ts:29-52 (registration)
    The tool registration in the ListTools response, including name, description, and inputSchema defining parameters for input/output paths, dimensions, fit mode, and aspect ratio preservation.
      name: 'resize_image',
      description: 'Resize an image to specified dimensions',
      inputSchema: {
        type: 'object',
        properties: {
          inputPath: { type: 'string', description: 'Path to input image' },
          outputPath: { type: 'string', description: 'Path to save resized image' },
          width: { type: 'number', description: 'Target width in pixels' },
          height: { type: 'number', description: 'Target height in pixels' },
          fit: {
            type: 'string',
            enum: ['cover', 'contain', 'fill', 'inside', 'outside'],
            description: 'How the image should be resized to fit',
            default: 'cover'
          },
          preserveAspectRatio: {
            type: 'boolean',
            description: 'Maintain original aspect ratio',
            default: true
          }
        },
        required: ['inputPath', 'outputPath']
      }
    },
  • The input schema for the resize_image tool, specifying the object structure, properties with types and descriptions, required fields, and defaults.
    inputSchema: {
      type: 'object',
      properties: {
        inputPath: { type: 'string', description: 'Path to input image' },
        outputPath: { type: 'string', description: 'Path to save resized image' },
        width: { type: 'number', description: 'Target width in pixels' },
        height: { type: 'number', description: 'Target height in pixels' },
        fit: {
          type: 'string',
          enum: ['cover', 'contain', 'fill', 'inside', 'outside'],
          description: 'How the image should be resized to fit',
          default: 'cover'
        },
        preserveAspectRatio: {
          type: 'boolean',
          description: 'Maintain original aspect ratio',
          default: true
        }
      },
      required: ['inputPath', 'outputPath']
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 states the tool resizes images but doesn't mention potential side effects like overwriting output files, performance considerations for large images, or error handling for invalid inputs. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, 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?

For a tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like file handling, error cases, or output specifics, leaving the agent with insufficient context to use the tool effectively beyond basic invocation.

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?

Schema description coverage is 100%, so the schema fully documents all 6 parameters. The description adds no additional meaning beyond what's in the schema, such as explaining the practical use of 'fit' options or 'preserveAspectRatio'. Baseline 3 is appropriate since the schema does the heavy lifting.

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 clearly states the action ('Resize') and resource ('an image') with the specific purpose of adjusting dimensions. It distinguishes from siblings like 'crop_image' or 'rotate_image' by focusing on resizing, though it doesn't explicitly differentiate from 'batch_resize' which handles multiple images.

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 like 'batch_resize' for multiple images or 'compress_image' for size reduction. The description lacks context about prerequisites, such as needing valid image paths, or exclusions for when other tools might be more appropriate.

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/flowy11/imagician'

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