imgcli AGENTS.md

Instructions for using imgcli, a command-line tool that converts and processes image files. It explains its options, supported formats, automation rules, and machine-readable JSON output.

In plain words
What is it for?
Use it to convert images, apply ordered filters, read image information, process files through standard input and output, and parse results in automation.
Why use it?
It gives coding agents a predictable way to process images without prompts, network access, or having to interpret human-formatted output.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/swperb/imgcli/agents-md
Clone the repo
git clone --depth 1 https://github.com/swperb/imgcli

Made for: Codex, OpenCode.

Per session 1,265 This file is loaded in full into every session.
When invoked 1,265 The same file — it is already loaded in full.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01265 $0.01265
Opus 5 $0.00633 $0.00633
Sonnet 5 $0.00253 $0.00253
Haiku 4.5 $0.00127 $0.00127

Measured yesterday against content hash 158f8016e036, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

imgcli AGENTS.md scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

make && sudo make install # -> imgcli on PATH ; needs only a C compiler + libm
AGENTS.md · 91 lines

How it starts

The opening of the file, as written. The whole thing — 91 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — using imgcli from an agent

Token-economical guide for AI agents and scripts. imgcli is a single, no-dependency C binary that converts and processes images. It is deterministic, non-interactive, and emits machine-readable JSON.

One-line mental model

imgcli [-i INPUT]... [-vf "FILTER,FILTER,..."] [-q N] [-f FMT] -y [--json] OUTPUT

Output format = OUTPUT's extension, or -f FMT (png, jpg, bmp, tga, ppm, qoi). Filters run left→right. INPUT and OUTPUT may be - for stdin/stdout (pipes); -f is required for stdout. When OUTPUT is -, the JSON/result line goes to stderr so stdout carries only the image bytes.

Always do this in automation

  • Pass -y (overwrite without prompting) and --json (parseable result).
  • imgcli never prompts and never uses the network. One process per conversion.

Build / install (once)

make && sudo make install      # -> imgcli on PATH ; needs only a C compiler + libm

JSON contract

Success (stdout, exit 0):

{"ok":true,"output":"out.png","width":256,"height":171,"format":"png","bytes":34122}

-info --json (stdout, exit 0):

{"ok":true,"inputs":[{"path":"in.jpg","width":4000,"height":3000,"channels":4}]}

--dry-run --json — validate a graph + get output dims without writing (stdout, exit 0):

{"ok":true,"dry_run":true,"width":512,"height":341,"format":"png"}

--out-dir … --json — batch; one result per input, exit ≠ 0 if any failed:

{"ok":true,"batch":true,"results":[{"input":"a.jpg","output":"out/a.png","ok":true,"width":400,"height":300,"bytes":34122},{"input":"bad.png","ok":false,"error":"…"}],"processed":2,"failed":1}

Error (stderr, exit ≠ 0):

{"ok":false,"error":"cannot open input 'x.png': ..."}

Exit codes

code meaning
0 success
1 runtime error (decode / filter / write)
2 usage error (bad or missing arguments)

Recipes (intent → command)

Intent Command
Convert format imgcli -y -i in.png out.jpg
Resize to width 800, keep aspect imgcli -y -i in.jpg -vf "scale=800:-1" out.jpg
Resize to exact box imgcli -y -i in.jpg -vf "scale=512:512" out.png
Make a thumbnail (HQ downscale) imgcli -y -i in.jpg -vf "scale=256:-1:lanczos" -q 80 thumb.jpg
Crop centre 400×400 imgcli -y -i in.jpg -vf "crop=400:400" out.png
Rotate 90° imgcli -y -i in.jpg -vf "transpose=90" out.png
Grayscale imgcli -y -i in.jpg -vf "grayscale" out.png
Compress JPEG (quality 60) imgcli -y -q 60 -i in.png out.jpg
Blur imgcli -y -i in.jpg -vf "gblur=3" out.png
Overlay a logo at 20,20 imgcli -y -i bg.png -i logo.png -vf "overlay=20:20" out.png
Probe dimensions only imgcli --json -info -i in.jpg
Validate a filtergraph (write nothing) imgcli --json --dry-run -i in.jpg -vf "scale=512:-1,grayscale"
Chain several ops imgcli -y -i in.jpg -vf "scale=1024:-1,grayscale,contrast=1.2,gblur=1" out.png
Pipe (stdin → stdout) … | imgcli -i - -vf "scale=512:-1" -f png - > out.png
Batch a folder imgcli --json -i "in/*.jpg" --out-dir out -vf "scale=400:-1:lanczos" -f png

Read the full file on GitHub · 91 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 91 lines · 1,265 tokens per session scan B 158f8016e036

Subscribe to this mod's changes

imgcli AGENTS.md is an instructions file published in the GitHub repository swperb/imgcli (0 stars, last pushed 15d ago), licensed MIT. It adds 1,265 tokens to every session, about $0.0063 per session on Opus 5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.