Skip to main content
Glama

read-jfif

Extract JFIF metadata from images using path, URL, base64, or buffer inputs. Designed for offline use, enabling detailed analysis of image information without external tools.

Instructions

Read JFIF metadata from an image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • The segmentTools array defining the 'read-jfif' tool registration with segment 'JFIF'.
    const segmentTools = [ { name: 'read-icc', segment: 'ICC' }, { name: 'read-iptc', segment: 'IPTC' }, { name: 'read-jfif', segment: 'JFIF' }, { name: 'read-ihdr', segment: 'IHDR' } ] as const;
  • Loop that iterates over segmentTools to register each tool (including read-jfif) with MCP server, defining schema, description, and shared handler.
    segmentTools.forEach(({ name, segment }) => { const segmentTool = server.tool(name, `Read ${segment} metadata from an image`, { image: ImageSourceSchema }, async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const opts = buildSegmentOptions(segment); const meta = await exifr.parse(buf, opts); const segmentKey = segment.toLowerCase(); if (!meta || !meta[segmentKey]) { return createErrorResponse(`No ${segment} metadata found in image`); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading ${segment} data: ${error instanceof Error ? error.message : String(error)}`); } } ); tools[name] = segmentTool; });
  • Shared handler for segment-specific tools like read-jfif: loads image buffer, configures exifr.parse for specific segment (JFIF), extracts and returns metadata or error.
    async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const opts = buildSegmentOptions(segment); const meta = await exifr.parse(buf, opts); const segmentKey = segment.toLowerCase(); if (!meta || !meta[segmentKey]) { return createErrorResponse(`No ${segment} metadata found in image`); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading ${segment} data: ${error instanceof Error ? error.message : String(error)}`); } }
  • ImageSourceSchema Zod validation schema for the image input parameter required by read-jfif 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() });
  • buildSegmentOptions function called in handler to create exifr options enabling only JFIF parsing for read-jfif tool.
    export function buildSegmentOptions(segment: 'ICC' | 'IPTC' | 'JFIF' | 'IHDR'): ExifrOptions { const options: ExifrOptions = { tiff: false, xmp: false, icc: false, iptc: false, jfif: false, ihdr: false, }; const key = segment.toLowerCase() as 'icc' | 'iptc' | 'jfif' | 'ihdr'; options[key] = true; return options; }

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