{"record":{"id":"4574a8bea786f16b","repo":"can1357/oh-my-pi","slug":"inspect-image-img-only-supports-svg-and-svgz","errorCode":null,"errorMessage":"inspect_image ':img' only supports .svg and .svgz files. / inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content.","messagePattern":"inspect_image ':img' only supports \\.svg and \\.svgz files\\. / inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content\\.","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/inspect-image.ts","lineNumber":250,"sourceCode":"\t\t\t\t});\n\t\t\t} else {\n\t\t\t\timageInput = await loadImageInput({\n\t\t\t\t\tpath: params.path,\n\t\t\t\t\tcwd: this.session.cwd,\n\t\t\t\t\tautoResize,\n\t\t\t\t\tmaxBytes: MAX_IMAGE_INPUT_BYTES,\n\t\t\t\t\texcludeWebP,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof ImageInputTooLargeError) {\n\t\t\t\tthrow new ToolError(error.message);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!imageInput) {\n\t\t\tthrow new ToolError(\n\t\t\t\tisSvgImage\n\t\t\t\t\t? \"inspect_image ':img' only supports .svg and .svgz files.\"\n\t\t\t\t\t: \"inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content.\",\n\t\t\t);\n\t\t}\n\n\t\tconst telemetry = resolveTelemetry(this.session.getTelemetry?.(), this.session.getSessionId?.() ?? undefined);\n\t\tconst timeoutMs = this.session.settings.get(\"inspect_image.timeoutMs\");\n\t\tconst hasTimeout = typeof timeoutMs === \"number\" && Number.isFinite(timeoutMs) && timeoutMs > 0;\n\t\tconst timeoutSignal = hasTimeout ? AbortSignal.timeout(timeoutMs) : undefined;\n\t\tconst effectiveSignal = timeoutSignal\n\t\t\t? signal\n\t\t\t\t? AbortSignal.any([signal, timeoutSignal])\n\t\t\t\t: timeoutSignal\n\t\t\t: signal;\n\t\tconst timedOut = (): boolean => Boolean(timeoutSignal?.aborted) && !signal?.aborted;\n\t\tconst formatTimeoutMessage = (): string => {\n\t\t\tconst seconds = timeoutMs % 1000 === 0 ? `${timeoutMs / 1000}` : (timeoutMs / 1000).toFixed(1);","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/inspect-image.ts#L232-L268","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","solutions":["Convert the image to PNG/JPEG/WEBP before inspecting.","For SVGs, pass the path with the ':img' selector (path.svg:img).","Verify the file is actually an image (`file image.png`) — fix extensions or point to the right file.","For PDFs, extract/render the page to PNG first, then inspect that."],"exampleFix":"// before\ninspect_image({ path: \"doc.pdf\", question: \"...\" })\n// after\n// $ magick doc.pdf[0] page.png\ninspect_image({ path: \"page.png\", question: \"...\" })","handlingStrategy":"validation","validationCode":"// Check magic bytes before calling\nconst head = new Uint8Array(await Bun.file(imagePath).slice(0, 12).arrayBuffer());\nconst isPng = head[0] === 0x89 && head[1] === 0x50;\nconst isJpeg = head[0] === 0xff && head[1] === 0xd8;\nconst isGif = head[0] === 0x47 && head[1] === 0x49;\nconst isWebp = head[8] === 0x57 && head[9] === 0x45 && head[10] === 0x42 && head[11] === 0x50;\nconst isSvg = (await Bun.file(imagePath).slice(0, 256).text()).includes(\"<svg\");\nif (!(isPng || isJpeg || isGif || isWebp || (isSvg && imagePath.endsWith(\":img\") === false))) {\n  // convert to PNG/JPEG first (or append ':img' for SVGs)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await inspectImageTool.execute(id, params, signal);\n} catch (e) {\n  if (e instanceof ToolError && e.message.includes(\"only supports\")) {\n    // convert the file to a supported raster format and retry\n  } else throw e;\n}","preventionTips":["Only pass PNG/JPEG/GIF/WEBP files; convert BMP/TIFF/HEIC/AVIF/PDF first.","Append ':img' to the path when inspecting SVG/SVGZ files.","Verify actual file type by content (e.g. `file` command), not by extension."],"tags":["image","file-format","validation"],"backgroundTag":"unsupported-file-format","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}