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'] } },

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