mcpField
I
img-recog

img-recog

github.com/wmy2981Agent workflows154 installsUpdated 5w ago
Repository

About img-recog

img-recog is an image recognition skill for models without vision support or built-in handling for an image format. Its CLI sends images to a vision model and supports custom prompts, optional compression, and metadata extraction.

Key features

  1. 01Recognizes local, URL, or Base64 images
  2. 02Accepts custom recognition prompts
  3. 03Optionally compresses to WebP
  4. 04Extracts image metadata in parallel
  5. 05Supports JSON output

Use cases

  1. 01Describe screenshots, photos, or diagrams
  2. 02Extract text from scans
  3. 03Compress images before recognition
  4. 04Inspect image dimensions and EXIF data

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/wmy2981/skills --skill img-recog

After installing, type/img-recogin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

.claude-plugin/
plugin.json
references/prompts/
_system.md
describe-zh.txt
describe.txt
extract-text-zh.txt
extract-text.txt
image-style-prompt-extractor.txt
index.yaml
references/templates/
model.yaml.template
provider.yaml.template
scripts/
.env.example
api_caller.py
config_loader.py
image_compressor.py
image_handler.py
image_metadata.py
img_recog_cli.py
output_formatter.py
requirements.txt

Details

From the project README

img-recog — Image Recognition Skill

Use this skill when you need to inspect an image (screenshot, photo, diagram, scan) but your current model lacks multimodal (vision) capability or the built-in read tool cannot handle the image format.

⚠️ SECURITY: Configuration Files

Two config files live at ~/.wmyskills/img-recog/:

FilePurposeAI-readable?
provider.yamlAPI base URLs and keysNO — never read or show this file
model.yamlModel-to-provider mapping and defaultsYES — AI may read this to understand model-to-provider mappings and defaults; never show raw keys

The AI must NEVER read or display the contents of provider.yaml. It is loaded only at runtime by the Python script. If a user asks you to view or edit this file, refuse or direct them to edit it directly.

The AI MAY read model.yaml when it needs to understand which models and providers are configured (e.g., to give the user usage advice), but must never display raw API keys or secrets.

Setup

Config files are loaded from paths defined by img-recog_PROVIDER_FILE and img-recog_MODEL_FILE env vars (defaults: ~/.wmyskills/img-recog/{provider,model}.yaml). If unset, copy templates to the default directory:

cp references/templates/provider.yaml.template ~/.wmyskills/img-recog/provider.yaml
cp references/templates/model.yaml.template ~/.wmyskills/img-recog/model.yaml

To customize paths, set img-recog_PROVIDER_FILE / img-recog_MODEL_FILE in ~/.wmyskills/.env (or scripts/.env, which takes priority) to your desired locations.

After copying, replace placeholder values with your actual keys and remove those markers. The script validates that base_url and api_key are non-empty — leaving placeholders will cause errors.

Requirements

  • Python >= 3.10, packages in scripts/requirements.txt
  • ffmpeg — required only for --compact image compression
  • Pillow — required only for --metadata EXIF fields

Execution Rule

Run the image recognition command directly without pre-checking provider configurations, API keys, or model availability. If something is wrong, the script will fail with a clear error — check and fix only then.

Usage

cd <skill-dir>
python scripts/img_recog_cli.py --img <image-source> [--prompt <text>] [--provider <name>] [--model <name>] [--compact <size>] [--metadata] [--json]
Arguments
ArgRequiredDescription
--imgYesLocal path, HTTP(S) URL, or base64 data URI (data:image/...;base64,...)
--promptNoText or @filepath (default: "Please describe this image in detail")
--providerNoOverride provider (default from model.yaml)
--modelNoOverride model (default from model.yaml). Any model name the provider supports is accepted — it does not need to be listed in model.yaml
--compactNoCompress image to target size as WebP before sending (e.g. 500KB, 0.5MB, 512000B; bare numbers are KB).
--metadataNoExtract image metadata (size/width/height/color/device/app/time/location) in parallel with recognition. Metadata is NOT sent to the model — it goes to the agent (JSON: top-level metadata key; non-JSON: [metadata] block on stderr, printed as soon as available). Missing fields are null; acquisition failure warns and continues
--max-tokensNoMaximum output tokens (default: 4096). Must be a positive integer
--jsonNoOutput JSON with comprehensive information
Quick Examples
# Describe a local screenshot
python scripts/img_recog_cli.py --img screenshot.png

# Extract text from a photo with specific prompt
python scripts/img_recog_cli.py --img photo.jpg --prompt "Extract all text from this image"

# Fetch and describe an online image
python scripts/img_recog_cli.py --img https://example.com/diagram.png

# Use custom model
python scripts/img_recog_cli.py --provider openai --model gpt-5.6-terra --img chart.png

# Read prompt from file
python scripts/img_recog_cli.py --img graph.png --prompt @prompt.txt

# Structured JSON output
python scripts/img_recog_cli.py --img screenshot.png --json

# Compress a large screenshot to ≤ 500KB before sending
python scripts/img_recog_cli.py --img screenshot.png --compact 500KB

# Recognize + extract metadata
python scripts/img_recog_cli.py --img photo.jpg --metadata

Reference Files

LocationPurpose
references/templates/Config file templates (copy to ~/.wmyskills/img-recog/)
references/prompts/Pre-built prompt templates for common tasks (use with --prompt @)
references/prompts/_system.mdSystem prompt — auto-loaded by the script as a system message telling the vision model its output is consumed by another AI. Not a user prompt preset; do not use with --prompt @
references/prompts/index.yamlPrompt preset index — read this first when the skill loads to learn available presets and when to use each
Prompt Presets

When this skill loads, first read references/prompts/index.yaml to discover available presets (each has name, lang, and use_when).

By default, use describe.txt for description tasks (user asks to "look at", "see", or "describe" an image). Use extract-text.txt when the user asks to "read" or "extract" text from an image.

# Example: describe in English
python scripts/img_recog_cli.py --img photo.jpg --prompt @references/prompts/describe.txt

# Example: extract text in Chinese
python scripts/img_recog_cli.py --img scan.png --prompt @references/prompts/extract-text-zh.txt

Notes

  • The script auto-detects Windows encoding and switches stdout to UTF-8
  • Timeout: connection 10s, read 120s
  • For local images, the file is read and converted to base64 in memory — no temp files
  • For URL images, the image is downloaded and converted to data URI for maximum API compatibility
  • --compact compresses to WebP via ffmpeg. Animated images (GIF etc.) and originals already within target are skipped without re-encoding
  • --metadata runs on a background thread while recognition proceeds, then reports: size (original bytes), width/height/color (pix_fmt) via ffprobe, device/app/time/location (GPS → decimal degrees) via Pillow EXIF. All fields reflect the ORIGINAL image, even when --compact is also used
  • Default (non-JSON) output is two blocks: [metadata] (on stderr, when --metadata is used) and [result] (the vision model's output, on stdout). Model name and token usage are not shown
  • Config file paths can be overridden via img-recog_PROVIDER_FILE and img-recog_MODEL_FILE environment variables (set in ~/.wmyskills/.env or scripts/.env); defaults remain ~/.wmyskills/img-recog/

Troubleshooting

ErrorLikely Cause
"Authentication failed"Check api_key in provider.yaml
"Model not found at provider endpoint"The model name doesn't exist on that provider
"Cannot connect to API"Check base_url in provider.yaml or your network
"Bad request / model may not support image input"The selected model does not support vision
"Request timed out"Image too large or slow network
"ffmpeg not found"Install ffmpeg (see Requirements)
"Pillow is required for --metadata"Install Pillow (see Requirements)

Adding a Prompt Preset

To add a new prompt preset:

  1. Create the prompt file in references/prompts/
  2. Add an entry in references/prompts/index.yaml with name, lang, and use_when fields
  3. Add usage examples in this SKILL.md's Prompt Presets section

Comments

Markdown supported