Skip to main content
Glama

gps-coordinates

Extract precise latitude and longitude coordinates from image metadata using the exifr library. Supports input formats like paths, URLs, base64, or buffers for offline processing.

Instructions

Extract GPS coordinates (latitude/longitude) from image metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • The handler function for the 'gps-coordinates' tool. Loads the image buffer using loadImage, extracts GPS coordinates with exifr.gps, returns success response with GPS data or null, or error if failed.
    async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const gps = await exifr.gps(buf); return createSuccessResponse(gps || null); } catch (error) { return createErrorResponse(`Error reading GPS data: ${error instanceof Error ? error.message : String(error)}`); } }
  • Input schema for the gps-coordinates tool, defining the required 'image' parameter using the shared ImageSourceSchema.
    { image: ImageSourceSchema },
  • Shared Zod schema for ImageSource used in gps-coordinates and other image tools, supporting path, url, base64 data, or buffer inputs.
    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() });
  • Registration of the gps-coordinates tool using server.tool, including name, description, schema, handler, and assignment to tools object.
    // Tool 10: gps-coordinates - extracts GPS coordinates const gpsCoordinatesTool = server.tool('gps-coordinates', "Extract GPS coordinates (latitude/longitude) from image metadata", { image: ImageSourceSchema }, async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const gps = await exifr.gps(buf); return createSuccessResponse(gps || null); } catch (error) { return createErrorResponse(`Error reading GPS data: ${error instanceof Error ? error.message : String(error)}`); } } ); tools['gps-coordinates'] = gpsCoordinatesTool;

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

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