Skip to main content
Glama

orientation

Extract image orientation values (1-8) from EXIF metadata to determine correct display rotation for images from files, URLs, or encoded data.

Instructions

Get image orientation value (1-8)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • The handler function that executes the 'orientation' tool logic: loads the image into a buffer, extracts the orientation value (1-8) using exifr.orientation, and returns a success response with the value or an appropriate error.
    async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const orientation = await exifr.orientation(buf); if (orientation === undefined) { return createErrorResponse('No orientation metadata found in image'); } return createSuccessResponse({ orientation }); } catch (error) { return createErrorResponse(`Error reading orientation: ${error instanceof Error ? error.message : String(error)}`); } }
  • Zod input schema for the 'image' parameter, defining supported source kinds (path, url, base64, buffer) used by the 'orientation' tool.
    const ImageSourceSchema = z.object({ kind: z.enum(['path', 'url', 'base64', 'buffer']), path: z.string().optional(), url: z.string().optional(), data: z.string().optional(), buffer: z.string().optional() });
  • Registers the 'orientation' tool with the MCP server via server.tool(), providing name, description, input schema, and handler function. Also stores reference for testing.
    const orientationTool = server.tool('orientation', "Get image orientation value (1-8)", { image: ImageSourceSchema }, async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const orientation = await exifr.orientation(buf); if (orientation === undefined) { return createErrorResponse('No orientation metadata found in image'); } return createSuccessResponse({ orientation }); } catch (error) { return createErrorResponse(`Error reading orientation: ${error instanceof Error ? error.message : String(error)}`); } } ); tools['orientation'] = orientationTool;

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/stass/exif-mcp'

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