flip_image
Flip images horizontally or vertically to correct orientation or create mirrored effects. Specify direction and paths to transform images with this editing tool.
Instructions
Flip an image horizontally or vertically
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputPath | Yes | Path to input image | |
| outputPath | Yes | Path to save flipped image | |
| direction | Yes | Flip direction |
Implementation Reference
- src/index.ts:340-364 (handler)Handler for flip_image tool: creates output dir, uses Sharp pipeline to flop (horizontal) and/or flip (vertical) based on direction, saves file, returns success message.case 'flip_image': { const { inputPath, outputPath, direction } = args; await fs.mkdir(path.dirname(outputPath), { recursive: true }); let pipeline = sharp(inputPath); if (direction === 'horizontal' || direction === 'both') { pipeline = pipeline.flop(); } if (direction === 'vertical' || direction === 'both') { pipeline = pipeline.flip(); } await pipeline.toFile(outputPath); return { content: [ { type: 'text', text: `Image flipped ${direction} successfully. Saved to: ${outputPath}` } ] }; }
- src/index.ts:141-153 (schema)Input schema definition for flip_image tool, specifying inputPath, outputPath, and direction (horizontal, vertical, both).inputSchema: { type: 'object', properties: { inputPath: { type: 'string', description: 'Path to input image' }, outputPath: { type: 'string', description: 'Path to save flipped image' }, direction: { type: 'string', enum: ['horizontal', 'vertical', 'both'], description: 'Flip direction' } }, required: ['inputPath', 'outputPath', 'direction'] }
- src/index.ts:138-154 (registration)Registration of the flip_image tool in the tools list returned by ListToolsRequestHandler.{ name: 'flip_image', description: 'Flip an image horizontally or vertically', inputSchema: { type: 'object', properties: { inputPath: { type: 'string', description: 'Path to input image' }, outputPath: { type: 'string', description: 'Path to save flipped image' }, direction: { type: 'string', enum: ['horizontal', 'vertical', 'both'], description: 'Flip direction' } }, required: ['inputPath', 'outputPath', 'direction'] } },