Skip to main content
Glama

convert_format

Convert images between formats (JPEG, PNG, WebP, AVIF) with specified quality settings using Imagician’s MCP server. Input source and target paths to transform images efficiently.

Instructions

Convert image between formats (jpeg, png, webp, avif)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatYesTarget format
inputPathYesPath to input image
outputPathYesPath to save converted image
qualityNoQuality for lossy formats (1-100)

Implementation Reference

  • The handler function for the 'convert_format' tool. It destructures arguments, ensures output directory exists, creates a Sharp pipeline for the input image, applies the specified format (with quality), saves to output path, and returns a success message.
    case 'convert_format': { const { inputPath, outputPath, format, quality = 80 } = args; await fs.mkdir(path.dirname(outputPath), { recursive: true }); let pipeline = sharp(inputPath); switch (format) { case 'jpeg': case 'jpg': pipeline = pipeline.jpeg({ quality, progressive: true }); break; case 'png': pipeline = pipeline.png({ quality }); break; case 'webp': pipeline = pipeline.webp({ quality }); break; case 'avif': pipeline = pipeline.avif({ quality }); break; } await pipeline.toFile(outputPath); return { content: [ { type: 'text', text: `Image converted to ${format} format. Saved to: ${outputPath}` } ] }; }
  • Input schema for the 'convert_format' tool defining parameters: inputPath, outputPath, format (enum), and optional quality.
    inputSchema: { type: 'object', properties: { inputPath: { type: 'string', description: 'Path to input image' }, outputPath: { type: 'string', description: 'Path to save converted image' }, format: { type: 'string', enum: ['jpeg', 'jpg', 'png', 'webp', 'avif'], description: 'Target format' }, quality: { type: 'number', minimum: 1, maximum: 100, description: 'Quality for lossy formats (1-100)', default: 80 } }, required: ['inputPath', 'outputPath', 'format'] }
  • src/index.ts:53-76 (registration)
    Registration of the 'convert_format' tool in the ListTools response, including name, description, and input schema.
    { name: 'convert_format', description: 'Convert image between formats (jpeg, png, webp, avif)', inputSchema: { type: 'object', properties: { inputPath: { type: 'string', description: 'Path to input image' }, outputPath: { type: 'string', description: 'Path to save converted image' }, format: { type: 'string', enum: ['jpeg', 'jpg', 'png', 'webp', 'avif'], description: 'Target format' }, quality: { type: 'number', minimum: 1, maximum: 100, description: 'Quality for lossy formats (1-100)', default: 80 } }, required: ['inputPath', 'outputPath', 'format'] } },

Other Tools

Related 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