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

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