flip_image
Flip an image horizontally, vertically, or both. Specify the input and output paths along with the desired flip direction to create mirrored or inverted versions of your image.
Instructions
Flip an image horizontally or vertically
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | Yes | Flip direction | |
| inputPath | Yes | Path to input image | |
| outputPath | Yes | Path to save flipped image |
Implementation Reference
- src/index.ts:340-364 (handler)Handler implementation for the flip_image tool. Processes the image using Sharp's flop() for horizontal and flip() for vertical flipping based on the direction ('horizontal', 'vertical', or 'both'), ensures output directory exists, and saves the flipped image.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:138-154 (registration)Registration of the flip_image tool in the ListToolsRequestSchema handler, defining the tool name, description, and input schema for validation.{ 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'] } },
- src/index.ts:141-153 (schema)Input schema for the flip_image tool, defining properties and requirements for inputPath, outputPath, and direction.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'] }