can1357/oh-my-pi · error · ToolError

inspect_image ':img' only supports .svg and .svgz files. / i

Error message

inspect_image ':img' only supports .svg and .svgz files. / inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content.

What it means

After all loading paths ran, imageInput came back null, meaning the loader could not decode the target as a supported image. Two variants: for an ':img' selection the file must be .svg/.svgz; otherwise the file must be PNG, JPEG, GIF, or WEBP as detected by file content (magic bytes), not extension. Unsupported formats (BMP, TIFF, PDF, HEIC, AVIF) or files whose content doesn't match any supported type produce this error.

Source

Thrown at packages/coding-agent/src/tools/inspect-image.ts:250

				});
			} else {
				imageInput = await loadImageInput({
					path: params.path,
					cwd: this.session.cwd,
					autoResize,
					maxBytes: MAX_IMAGE_INPUT_BYTES,
					excludeWebP,
				});
			}
		} catch (error) {
			if (error instanceof ImageInputTooLargeError) {
				throw new ToolError(error.message);
			}
			throw error;
		}

		if (!imageInput) {
			throw new ToolError(
				isSvgImage
					? "inspect_image ':img' only supports .svg and .svgz files."
					: "inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content.",
			);
		}

		const telemetry = resolveTelemetry(this.session.getTelemetry?.(), this.session.getSessionId?.() ?? undefined);
		const timeoutMs = this.session.settings.get("inspect_image.timeoutMs");
		const hasTimeout = typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0;
		const timeoutSignal = hasTimeout ? AbortSignal.timeout(timeoutMs) : undefined;
		const effectiveSignal = timeoutSignal
			? signal
				? AbortSignal.any([signal, timeoutSignal])
				: timeoutSignal
			: signal;
		const timedOut = (): boolean => Boolean(timeoutSignal?.aborted) && !signal?.aborted;
		const formatTimeoutMessage = (): string => {
			const seconds = timeoutMs % 1000 === 0 ? `${timeoutMs / 1000}` : (timeoutMs / 1000).toFixed(1);

View on GitHub (pinned to 9690622007)

Solutions

  1. Convert the image to PNG/JPEG/WEBP before inspecting.
  2. For SVGs, pass the path with the ':img' selector (path.svg:img).
  3. Verify the file is actually an image (`file image.png`) — fix extensions or point to the right file.
  4. For PDFs, extract/render the page to PNG first, then inspect that.

Example fix

// before
inspect_image({ path: "doc.pdf", question: "..." })
// after
// $ magick doc.pdf[0] page.png
inspect_image({ path: "page.png", question: "..." })
Defensive patterns

Strategy: validation

Validate before calling

// Check magic bytes before calling
const head = new Uint8Array(await Bun.file(imagePath).slice(0, 12).arrayBuffer());
const isPng = head[0] === 0x89 && head[1] === 0x50;
const isJpeg = head[0] === 0xff && head[1] === 0xd8;
const isGif = head[0] === 0x47 && head[1] === 0x49;
const isWebp = head[8] === 0x57 && head[9] === 0x45 && head[10] === 0x42 && head[11] === 0x50;
const isSvg = (await Bun.file(imagePath).slice(0, 256).text()).includes("<svg");
if (!(isPng || isJpeg || isGif || isWebp || (isSvg && imagePath.endsWith(":img") === false))) {
  // convert to PNG/JPEG first (or append ':img' for SVGs)
}

Try / catch

try {
  await inspectImageTool.execute(id, params, signal);
} catch (e) {
  if (e instanceof ToolError && e.message.includes("only supports")) {
    // convert the file to a supported raster format and retry
  } else throw e;
}

Prevention

When it happens

Trigger: inspect_image on a non-raster file (BMP/TIFF/HEIC/AVIF/PDF/HTML), a text file misnamed .png, or an ':img' selector applied to a non-SVG file; also SVGs passed without the ':img' selector are not loaded as raster paths here.

Common situations: Agent tries to inspect a PDF or .bmp; downloaded image is actually WebP/AVIF variant in disguise and outside supported decoding; user renames files with wrong extensions; passing an SVG path without appending ':img'.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/4574a8bea786f16b. Report an issue: GitHub.