Skip to main content
Glama

read-iptc

Extract IPTC metadata from images to access embedded information like captions, keywords, and copyright details for content management and analysis.

Instructions

Read IPTC metadata from an image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • segmentTools array that includes the configuration for the 'read-iptc' tool with segment 'IPTC', used in the subsequent registration loop.
    { name: 'read-icc', segment: 'ICC' }, { name: 'read-iptc', segment: 'IPTC' }, { name: 'read-jfif', segment: 'JFIF' }, { name: 'read-ihdr', segment: 'IHDR' } ] as const;
  • Dynamic registration loop that registers the 'read-iptc' tool using server.tool with description, schema, and shared handler function.
    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; });
  • Handler function executed for read-iptc: loads image, builds IPTC-specific exifr options, parses and returns IPTC metadata or appropriate 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)}`); } } );
  • Zod schema defining the input structure for the 'image' parameter required by the read-iptc 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() });
  • Helper function buildSegmentOptions that configures exifr.parse options specifically for IPTC by setting iptc: true when segment='IPTC'.
    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; }

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