Skip to main content
Glama

read-exif

Extract and filter EXIF metadata from images using various input formats, enabling precise analysis of image details without external dependencies.

Instructions

Read EXIF data from an image with optional tag filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes
pickNo

Implementation Reference

  • The core handler function for the 'read-exif' tool. It loads the image into a buffer using loadImage, builds EXIF-specific parsing options using buildExifOptions based on the optional 'pick' tags, parses the EXIF metadata with exifr.parse, checks if metadata was found, and returns a standardized success response with the EXIF data or an error response.
    async (args, extra) => { try { const { image, pick } = args; const buf = await loadImage(image); const opts = buildExifOptions(pick); const meta = await exifr.parse(buf, opts); if (!meta || Object.keys(meta).length === 0) { return createErrorResponse('No EXIF metadata found in image'); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading EXIF data: ${error instanceof Error ? error.message : String(error)}`); } }
  • Zod schema definition for ImageSource used as the 'image' input parameter in the read-exif tool schema.
    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() });
  • Input schema for the read-exif tool, including 'image' (ImageSourceSchema) and optional 'pick' array of EXIF tags to filter.
    { image: ImageSourceSchema, pick: z.array(z.string()).optional() },
  • Registration of the 'read-exif' tool using server.tool(), defining its name, description, input schema, and handler function. Also assigns to tools object for reference.
    const readExifTool = server.tool('read-exif', "Read EXIF data from an image with optional tag filtering", { image: ImageSourceSchema, pick: z.array(z.string()).optional() }, async (args, extra) => { try { const { image, pick } = args; const buf = await loadImage(image); const opts = buildExifOptions(pick); const meta = await exifr.parse(buf, opts); if (!meta || Object.keys(meta).length === 0) { return createErrorResponse('No EXIF metadata found in image'); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading EXIF data: ${error instanceof Error ? error.message : String(error)}`); } } ); tools['read-exif'] = readExifTool;
  • buildExifOptions helper function specifically for the read-exif tool, creates exifr options object enabling TIFF (for EXIF) and optionally filtering specific tags with 'pick'.
    /** * Creates options object for the read-exif tool * @param pick Optional array of specific EXIF tags to pick * @returns Options object configured for EXIF reading */ export function buildExifOptions(pick?: string[]): ExifrOptions { return { tiff: true, xmp: false, icc: false, iptc: false, jfif: false, ihdr: false, ...(pick ? { pick } : {}) }; }

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