Skip to main content
Glama

crop_image

Crop images to specific dimensions by defining pixel coordinates for left, top, width, and height parameters within the Imagician server's editing toolkit.

Instructions

Crop an image to specified region

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesPath to input image
outputPathYesPath to save cropped image
leftYesLeft offset in pixels
topYesTop offset in pixels
widthYesWidth of crop area
heightYesHeight of crop area

Implementation Reference

  • Handler for 'crop_image' tool: destructures args, ensures output dir, uses sharp.extract() to crop the image region specified by left, top, width, height, saves to outputPath, returns success message.
    case 'crop_image': {
      const { inputPath, outputPath, left, top, width, height } = args;
      
      await fs.mkdir(path.dirname(outputPath), { recursive: true });
      
      await sharp(inputPath)
        .extract({ left, top, width, height })
        .toFile(outputPath);
      
      return {
        content: [
          {
            type: 'text',
            text: `Image cropped successfully. Saved to: ${outputPath}`
          }
        ]
      };
    }
  • Schema definition for 'crop_image' tool in ListTools response, including inputSchema with properties for image paths and crop parameters (left, top, width, height), all required.
      name: 'crop_image',
      description: 'Crop an image to specified region',
      inputSchema: {
        type: 'object',
        properties: {
          inputPath: { type: 'string', description: 'Path to input image' },
          outputPath: { type: 'string', description: 'Path to save cropped image' },
          left: { type: 'number', description: 'Left offset in pixels' },
          top: { type: 'number', description: 'Top offset in pixels' },
          width: { type: 'number', description: 'Width of crop area' },
          height: { type: 'number', description: 'Height of crop area' }
        },
        required: ['inputPath', 'outputPath', 'left', 'top', 'width', 'height']
      }
    },
  • src/index.ts:78-92 (registration)
    Registration of 'crop_image' tool in the tools list returned by ListToolsRequestHandler.
      name: 'crop_image',
      description: 'Crop an image to specified region',
      inputSchema: {
        type: 'object',
        properties: {
          inputPath: { type: 'string', description: 'Path to input image' },
          outputPath: { type: 'string', description: 'Path to save cropped image' },
          left: { type: 'number', description: 'Left offset in pixels' },
          top: { type: 'number', description: 'Top offset in pixels' },
          width: { type: 'number', description: 'Width of crop area' },
          height: { type: 'number', description: 'Height of crop area' }
        },
        required: ['inputPath', 'outputPath', 'left', 'top', 'width', 'height']
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action 'crop an image' but doesn't mention whether this is a destructive operation (overwrites the original?), requires specific file permissions, handles errors (e.g., invalid paths), or has performance considerations. For a mutation tool with zero annotation coverage, this is a significant gap.

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 any unnecessary words. It's front-loaded with the core action, 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 complexity of an image manipulation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what the tool returns (e.g., success status, error messages), behavioral traits like file handling or error conditions, or usage context relative to siblings. This leaves the agent with insufficient information for reliable 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 already documents all six parameters (inputPath, outputPath, left, top, width, height) with clear descriptions. The description adds no additional meaning beyond implying cropping uses a region defined by these parameters, which is already evident from the schema. Baseline 3 is appropriate when 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 verb ('crop') and resource ('image') with the specific action 'to specified region'. It distinguishes from siblings like resize_image or rotate_image by focusing on cropping rather than resizing or rotating. However, it doesn't explicitly differentiate from batch_resize which handles multiple images, leaving some ambiguity.

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 like resize_image (for changing dimensions) or batch_resize (for processing multiple images). There's no mention of prerequisites, such as needing an existing image file, or exclusions, like not handling non-image files.

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