Skip to main content
Glama

Image to Base64 / data URI

image_to_base64
Read-onlyIdempotent

Encode images or files as Base64 for embedding as data URIs, CSS, HTML, Markdown, or SVG URIs; detects MIME type, warns when inline size is too large, and saves oversized output to a text file.

Instructions

Encode an image (or any file) as Base64: a data URI, bare Base64, a CSS background-image rule, an HTML tag (with width/height), Markdown, or for SVG a URL-encoded data URI (usually ~30% smaller). Detects the type from the bytes and warns when the result is too big to inline (over 10 KB: slows pages; over 1 MB: use a normal file). Results longer than maxChars are written to a .txt file instead of being returned. Web version: https://s3eidat.github.io/image-to-base64/

Input Schema

NameRequiredDescriptionDefault
asNoWhat to return: dataUri (default), base64, css, html, markdown, or svgUri (SVG only).dataUri
imageYesThe image: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI).
outputNoWhere to write the result: a file path, or a folder ending in "/". Default: the server output folder (a temp folder unless --out-dir is set).
maxCharsNoLongest text returned inline; longer results go to a file. Default 200000.
mimeTypeNoOverride the detected MIME type (e.g. image/svg+xml).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the readOnly/idempotent annotations, it discloses real behavior: byte-level type detection, size-based warnings with thresholds, and the fact that over-maxChars results are written to a .txt file rather than returned. That file-spillover behavior is the kind of non-obvious trait an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense but front-loaded with the core action and output modes first, size warnings next, file-spillover and web link last. Nearly every clause carries information, though it is on the longer side.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description still covers return behavior (inline vs written file), type detection, and size limits, which is everything an agent needs to invoke it correctly. Annotations already cover the read-only safety profile.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaning: the SVG URI option is ~30% smaller, HTML output can carry width/height, and the maxChars-to-file behavior is restated. It enriches the enum semantics beyond the raw schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (encode) plus resource (image/any file) and enumerates the concrete output forms (data URI, base64, CSS, HTML img, Markdown, SVG URI). This clearly separates it from the pure reverse tool image_from_base64 and the generic text base64_encode, though it never names a sibling explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives usable context: it detects type from bytes and flags when results are too large to inline (10 KB warning, 1 MB cutoff). It does not explicitly say when to prefer base64_encode for plain text or image_from_base64 for the reverse, so there is no explicit exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools