Skip to main content
Glama

apply-effect

Transform images by applying effects like blur, sharpen, grayscale, or sepia using customizable intensity. Save processed files to a specified path or default Downloads folder.

Instructions

Apply visual effect to image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
effectYesEffect to apply
inputPathYesAbsolute path to input image file
intensityNoEffect intensity (0-100, not applicable for some effects)
outputFilenameNoOutput filename (only used if outputPath is not provided)
outputPathNoOptional absolute path for output file. If not provided, file will be saved in Downloads folder

Implementation Reference

  • src/index.ts:513-579 (registration)
    Registration of the 'apply-effect' MCP tool using server.tool, including inline schema and handler function.
    server.tool( "apply-effect", "Apply visual effect to image", { inputPath: z.string().describe("Absolute path to input image file"), effect: z.enum(['blur', 'sharpen', 'edge', 'emboss', 'grayscale', 'sepia', 'negate']).describe("Effect to apply"), intensity: z.number().min(0).max(100).default(50).describe("Effect intensity (0-100, not applicable for some effects)"), outputPath: z.string().optional().describe("Optional absolute path for output file. If not provided, file will be saved in Downloads folder"), outputFilename: z.string().optional().describe("Output filename (only used if outputPath is not provided)") }, async ({ inputPath, effect, intensity, outputPath, outputFilename }) => { try { await checkImageMagick(); const absoluteInputPath = await getAbsolutePath(inputPath); const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output'; const extension = absoluteInputPath.split('.').pop() || 'png'; const defaultFilename = outputFilename || `${inputFileName}_${effect}.${extension}`; const finalOutputPath = await getOutputPath(outputPath, defaultFilename); let command = ''; switch (effect) { case 'blur': command = `convert "${absoluteInputPath}" -blur 0x${intensity / 5} "${finalOutputPath}"`; break; case 'sharpen': command = `convert "${absoluteInputPath}" -sharpen 0x${intensity / 10} "${finalOutputPath}"`; break; case 'edge': command = `convert "${absoluteInputPath}" -edge ${intensity / 10} "${finalOutputPath}"`; break; case 'emboss': command = `convert "${absoluteInputPath}" -emboss ${intensity / 10} "${finalOutputPath}"`; break; case 'grayscale': command = `convert "${absoluteInputPath}" -colorspace Gray "${finalOutputPath}"`; break; case 'sepia': command = `convert "${absoluteInputPath}" -sepia-tone ${intensity}% "${finalOutputPath}"`; break; case 'negate': command = `convert "${absoluteInputPath}" -negate "${finalOutputPath}"`; break; } await execSync(command); return { content: [ { type: "text", text: `Effect successfully applied and saved to: ${finalOutputPath}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error applying effect: ${errorMessage}`, }, ], }; } } );
  • Handler that applies ImageMagick effects to images based on the 'effect' parameter (blur, sharpen, edge, emboss, grayscale, sepia, negate), handling paths and errors.
    async ({ inputPath, effect, intensity, outputPath, outputFilename }) => { try { await checkImageMagick(); const absoluteInputPath = await getAbsolutePath(inputPath); const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output'; const extension = absoluteInputPath.split('.').pop() || 'png'; const defaultFilename = outputFilename || `${inputFileName}_${effect}.${extension}`; const finalOutputPath = await getOutputPath(outputPath, defaultFilename); let command = ''; switch (effect) { case 'blur': command = `convert "${absoluteInputPath}" -blur 0x${intensity / 5} "${finalOutputPath}"`; break; case 'sharpen': command = `convert "${absoluteInputPath}" -sharpen 0x${intensity / 10} "${finalOutputPath}"`; break; case 'edge': command = `convert "${absoluteInputPath}" -edge ${intensity / 10} "${finalOutputPath}"`; break; case 'emboss': command = `convert "${absoluteInputPath}" -emboss ${intensity / 10} "${finalOutputPath}"`; break; case 'grayscale': command = `convert "${absoluteInputPath}" -colorspace Gray "${finalOutputPath}"`; break; case 'sepia': command = `convert "${absoluteInputPath}" -sepia-tone ${intensity}% "${finalOutputPath}"`; break; case 'negate': command = `convert "${absoluteInputPath}" -negate "${finalOutputPath}"`; break; } await execSync(command); return { content: [ { type: "text", text: `Effect successfully applied and saved to: ${finalOutputPath}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error applying effect: ${errorMessage}`, }, ], }; } }
  • Zod input schema for the apply-effect tool parameters.
    { inputPath: z.string().describe("Absolute path to input image file"), effect: z.enum(['blur', 'sharpen', 'edge', 'emboss', 'grayscale', 'sepia', 'negate']).describe("Effect to apply"), intensity: z.number().min(0).max(100).default(50).describe("Effect intensity (0-100, not applicable for some effects)"), outputPath: z.string().optional().describe("Optional absolute path for output file. If not provided, file will be saved in Downloads folder"), outputFilename: z.string().optional().describe("Output filename (only used if outputPath is not provided)") },

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/maoxiaoke/mcp-media-processor'

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