rotate_image
Rotate images by a specified angle, adjust background color for exposed areas, and save the output. Ideal for precise image orientation adjustments.
Instructions
Rotate an image by specified degrees
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| angle | Yes | Rotation angle in degrees (positive = clockwise) | |
| background | No | Background color for exposed areas (hex or named color) | #000000 |
| inputPath | Yes | Path to input image | |
| outputPath | Yes | Path to save rotated image |
Implementation Reference
- src/index.ts:321-338 (handler)Handler for rotate_image tool: extracts parameters, ensures output directory exists, rotates the image using sharp.rotate() with specified angle and background, saves to outputPath, and returns success message.case 'rotate_image': { const { inputPath, outputPath, angle, background = '#000000' } = args; await fs.mkdir(path.dirname(outputPath), { recursive: true }); await sharp(inputPath) .rotate(angle, { background }) .toFile(outputPath); return { content: [ { type: 'text', text: `Image rotated ${angle}° successfully. Saved to: ${outputPath}` } ] }; }
- src/index.ts:117-137 (registration)Registration of the rotate_image tool in the listTools response, including name, description, and input schema definition for validation.{ name: 'rotate_image', description: 'Rotate an image by specified degrees', inputSchema: { type: 'object', properties: { inputPath: { type: 'string', description: 'Path to input image' }, outputPath: { type: 'string', description: 'Path to save rotated image' }, angle: { type: 'number', description: 'Rotation angle in degrees (positive = clockwise)' }, background: { type: 'string', description: 'Background color for exposed areas (hex or named color)', default: '#000000' } }, required: ['inputPath', 'outputPath', 'angle'] } },