v0.1 live on PyPI

Images,
Acquired.
Verified.

imgagent is the image acquisition agent for autonomous software. One command takes a query from search → rank → download → verify → manifest and hands back bytes it has fully decoded, hashed and rights-checked. No browser. No LLM. No guesswork. stdout is a JSON contract; the manifest is the deliverable.

$pip install imgagent
See it work ↓ PyPI ↗ Agent manual ↗
0
Pipeline stages
0+
Image sources
0%
Decoded before delivery
0
Paid APIs required
agent@pipeline: ~/scene-04 — imgagent run
01 The pipeline

Seven gates.
Zero trust.

Every stage is independently callable. Nothing advances on faith — a candidate becomes an asset only after the bytes decode, hash and pass the rights gate.

01
🔍
Search
Multi-source discovery, each provider normalized to one schema.
02
🧬
Normalize
Every hit becomes an imgagent.candidate/v1 object.
03
📊
Rank
Deterministic relevance + quality scoring. Same input, same order.
04
♻️
Dedupe
Perceptual + exact-hash dedupe before a single byte downloads.
05
⚡
Download
Streaming, atomic .part writes, backoff retries, byte caps.
06
🛡
Verify
Magic bytes + full decode + SHA-256. Extensions prove nothing.
07
📜
Manifest
Paths, hashes, provenance, rights — one JSON deliverable.
02 Why it holds up

Built for machines
that don't guess.

SEC / 01
100%

Verified bytes, or nothing

A file is "downloaded" only after Pillow fully decodes it, the format matches its magic bytes, and the SHA-256 is recorded. HTML dressed as .jpg, corrupt files, bomb-sized payloads — rejected before they ever touch your assets.

  • Streaming downloads with atomic .part → rename
  • MIME + full decode + per-format policy (JPEG/PNG/WebP/GIF, opt. AVIF)
  • Perceptual-hash dedupe across jobs
✓
SEC / 02

Hardened by default

The network is hostile; imgagent treats it that way.

  • SSRF guards: loopback, private, link-local, cloud-metadata ranges
  • DNS-rebinding re-checks on every redirect hop
  • TLS verification never disabled — no debug escape hatch
  • Path-traversal-proof writes; downloads never executed
🛡
SEC / 03

Rights are data, not vibes

License, creator and source page ride on every asset. --require-reuse-rights admits only verified public-domain / licensed material. Unknown never passes the gate — no matter the score.

§
SEC / 04

Idempotent to the core

Kill it mid-run, rerun it tomorrow — stable candidate IDs, resumable jobs, verified files reused, SQLite state that survives restarts. Agents can retry without fear.

∞
SEC / 05

One JSON contract

stdout = exactly one JSON object. stderr = diagnostics. Exit codes 0/1/2/3 mean exactly one thing each. Your parser is 3 lines and never breaks.

{ }
03 The contract

Read the payload.
Ship the manifest.

Three views of the same system: what the CLI prints, what the manifest carries, and how your code calls it as a library.

// imgagent run "isdal woman norway 1970" --require-reuse-rights --top 2 --json
{
  "ok": true,
  "schema": "imgagent.result/v1",
  "command": "run",
  "data": {
    "job_id": "j-3f9c81a2",
    "downloads": { "saved": 2, "failed": 0, "duplicate": 0 },
    "manifest_path": "/work/.imgagent/manifests/j-3f9c81a2.json",
    "partial": false, "errors": []
  }
}
{
  "schema_version": "imgagent.manifest/v1",
  "assets": [{
    "asset_id": "asset-586f22ac8bf2",
    "project": "isdal", "scene": "scene-04",
    "file": { "path": "…/originals/isdalen--9ac9f850.jpg",
              "sha256": "586f…", "width": 3264, "height": 2448 },
    "provenance": { "provider": "wikimedia",
                    "source_page_url": "https://commons.wikimedia.org/…",
                    "creator": "…" , "license_name": "Public domain" },
    "rights_status": "verified_public_domain"
  }]
}
from imgagent import run_image_job, get_manifest

result = run_image_job(
    "Isdal Woman Norway 1970",
    top=8, require_reuse_rights=True,
    project="isdal", scene="scene-04",
)
manifest = get_manifest(result.job_id)
# same engine as the CLI — one implementation, one contract
// claude_desktop_config.json — or any MCP client
{
  "mcpServers": {
    "imgagent": {
      "command": "imgagent-mcp",
      "args": [],
      "env": { "IMGAGENT_WORKSPACE": "/abs/path/.imgagent" }
    }
  }
}
04 Providers

Plugged into
the open web.

Honest support matrix — every provider documents auth, rate limits and test date. If a source is down, it shows up in errors[]; the rest keep working.

Wikimedia Commons
Primary

Official MediaWiki API. Original-resolution files plus full license metadata — the backbone of rights-cleared workflows.

auth none · rights verified
formats jpeg · png · webp · gif · tif
Openverse
Licensed

CC-licensed index across millions of works. License and creator come with the result, not as a chase.

auth optional key · rights verified
formats jpeg · png · gif
DuckDuckGo Images
Discovery

Broad web discovery when coverage matters more than metadata. Rights stay unknown — by design, not by accident.

auth none · rights unknown
best for exploration, reference
Generic extractor
Any URL

Point inspect at any page or image URL: OG-image extraction, magic-byte sniffing, dimensions — no integration required.

auth n/a · use one-off probes
download explicit, verified
Custom JSON APIs
Your keys

Config-driven provider: declare an endpoint + field map in config.toml and your licensed archive behaves like a built-in.

auth env var keys
pipeline same verify + manifest
More coming
Roadmap

Google Images discovery and Pinterest reference inspection are on the roadmap behind the same candidate schema.

status not yet shipped
policy shipped = tested = documented
05 For agents

Drop it into
your agent stack.

CONTRACT · RUNTIME

Self-describing on purpose

Any agent can load the full operating manual straight from the binary — golden rules, command map, failure taxonomy, anti-patterns. No docs archaeology, no guessing flags.

$ imgagent agent-instructions
# complete machine contract on stdout —
# safe to paste into any system prompt
Read AGENTS.md ↗
MCP · TOOLS

Native tool server

The same engine exposed over Model Context Protocol. Claude Desktop, Cursor, or your own MCP client — tools mirror the CLI one-to-one, schemas and all.

pip install "imgagent[mcp]"

{ "mcpServers": { "imgagent": {
    "command": "imgagent-mcp" } } }
Full docs ↗
06 — Who's behind this

Built by the Ansari Bilal team.

imgagent is part of a family of headless, contract-first agents built for real production pipelines — the same doctrine that runs through ytagent, ttagent and igagent: one input, one JSON contract, verified bytes, honest negatives. Full story, other projects and contact live on the main site.

Ansari Bilal
Author & Owner — imgagent
LicenseMIT — free to build on
07 The ecosystem

One doctrine.
Many agents.

imgagent doesn't ship alone. Sibling agents cover video, search and media farms — all contract-first, all built to run unattended.

imgagent
↗

You're here. Image discovery → verified assets → manifest. The acquisition layer of the stack.

this projectpypimcp
ytagent
↗

YouTube acquisition agent with the same one-JSON contract — metadata, media, verification.

siblingvideoagent
ttagent
↗

TikTok-side sibling agent: URL normalization, slot decoding, atomic downloads.

siblingvideoagent
igagent
↗

Instagram media agent — source tracing and verified downloads under the same doctrine.

siblingmediaagent
yt-farm
↗

Remote worker / task execution farm with handoff patterns — where the agents run at scale.

infraworkersorchestration
Opuscar Studio
↗

The flagship consumer: asset inventory and video rendering that eats imgagent manifests directly.

consumerrenderstudio
lemo-opuscar
↗

Companion Opuscar build — asset pipelines and rendering integration in the same universe.

consumerpipeline
ansaribilal.com
↗

Home base — the maker's site with everything else: projects, writing, contact.

start hereportfolio