imgagent
Universal image discovery, search, listing, download and asset agent — standalone, headless, deterministic, machine-friendly.
🌐 Landing page · 📦 PyPI · 🤖 Agent manual (AGENTS.md) · 👤 ansaribilal.com
imgagent is a production-grade, installable image acquisition agent for AI agents and humans:
one command takes a query from search → normalize → rank → dedupe → download → validate →
manifest → verified local paths. Every stage is also independently callable. It runs fully
deterministic without any LLM, works headless on Linux / macOS / Windows / Termux / containers /
CI, and needs no paid API for its default public-source workflow.
pip install imgagent # live on PyPI
Sibling doctrine of ytagent, ttagent and igagent: one input, one JSON contract, verified bytes, honest negatives.
Quickstart
# From PyPI (published)
pip install imgagent
# or from a clone
pip install .
# One command: discover, rank, download the top 5, write the manifest
imgagent run "Isdal Woman Norway 1970 historical photographs" \
--limit 20 --top 5 --out ./assets --json
# Search only (no downloads)
imgagent search "Isdal Woman Bergen" --limit 30 --json
# List candidates of the latest job
imgagent list --job latest --json
# Download selected results
imgagent download --job latest --top 10 --out ./assets --project myfilm --scene scene-04 --json
# Inspect a URL without downloading its contents
imgagent inspect "https://commons.wikimedia.org/wiki/File:Isdal_Woman.jpg"
# The complete machine-facing contract
imgagent agent-instructions
One-command workflow
INPUT QUERY
→ SEARCH MULTIPLE SOURCES (wikimedia · openverse · duckduckgo · custom official APIs)
→ NORMALIZE RESULTS (single ImageCandidate schema, versioned)
→ RANK RELEVANCE (text + entity + technical + rights, deterministic, no LLM)
→ DEDUPLICATE (cross-provider URL dedup; SHA-256 + perceptual near-dup)
→ LIST CANDIDATES
→ DOWNLOAD SELECTED IMAGES (streaming, bounded concurrency, atomic .part)
→ VALIDATE FILES (magic bytes + full decode; never trust headers)
→ SAVE METADATA AND MANIFEST (.imgagent/manifests/<job>.json + metadata.jsonl)
→ RETURN VERIFIED PATHS
A broken provider never breaks the others: per-source failures come back as structured entries
in errors[], and a partial success is explicitly represented in the JSON payload.
Supported providers
| Provider | Type | API key | Default | Status | Notes |
|---|---|---|---|---|---|
wikimedia |
Official MediaWiki API | no | yes | tested | License metadata, originals, best historical coverage |
openverse |
Official Openverse API | optional (OPENVERSE_API_KEY) |
yes | tested | CC/public-domain focus, rights-cleared mode |
duckduckgo |
Community vqd flow (unofficial) | no | yes | best-effort | Volatile; failures are graceful and explicit |
generic |
Webpage extractor (og:image, JSON-LD, <img>) |
no | inspect-only | tested | Also resolves public Pinterest pin pages as page references |
custom:* |
Config-driven official APIs (Unsplash, Pexels, your own) | per-config | opt-in | tested | Declared in config.toml [sources.custom.*] |
Google Images is deliberately not implemented as fragile HTML scraping; use a configured official API (custom source) instead. No CAPTCHA, paywall, login or access-control bypass exists in this codebase. See docs/PROVIDERS.md for the full support matrix.
Verification & security
- Downloads are validated by magic bytes + full Pillow decode — HTML pages masquerading as images, corrupt files, empty files and oversized payloads are rejected.
- SHA-256 content hashing, exact-duplicate reuse, atomic
.part→ rename writes. - SSRF protection: http/HTTPS only, private/link-local/loopback ranges blocked, cloud metadata endpoints hard-blocked, redirect-by-redirect validation, response size caps.
- TLS verification is never disabled as a fallback. See docs/SECURITY.md.
Rights & provenance
Technical downloadability is separated from publication permission. Every asset records source URL, provider, creator, license name/URL, attribution text, retrieval timestamps, file hash, dimensions and a rights state:
verified_public_domain · verified_license · permission_required · unknown · restricted
--require-reuse-rights keeps only verified states — and a high relevance score can never
override that gate. Generic illustration and authentic case evidence remain distinguishable via
authenticity and --prefer-authentic.
Workspace layout
.imgagent/
config.toml # optional configuration
jobs/
database.sqlite # transactional job/candidate/asset state (WAL)
manifests/ # <job_id>.json — the stable contract for consumers
cache/ # TTL JSON cache for API responses
assets/
<project>/
originals/ # verified originals only
processed/
thumbnails/
metadata.jsonl # one record per downloaded asset
The workspace is configurable (--workspace, IMGAGENT_WORKSPACE); jobs resume after
interruption and repeated invocations never re-download verified files.
Machine integration
--jsonemits exactly one JSON object on stdout; diagnostics go to stderr, always.- Exit codes:
0success (incl. explicit partial),1no usable results,2usage,3config/dependency. imgagent agent-instructionsprints the complete contract an agent can follow without a human.- Optional MCP server (
pip install 'imgagent[mcp]'+imgagent-mcp) wraps the same functions. - Programmatic API:
from imgagent import api—search_images,list_candidates,download_selected,run_image_job,get_manifest, … See docs/API_REFERENCE.md.
Configuration
Copy config.example.toml into .imgagent/config.toml or set
environment variables (IMGAGENT_*). Everything works with defaults; API keys are read from
environment variables only and are never logged.
Environments
Python ≥ 3.10, ~2 runtime dependencies (httpx, Pillow). CPU-only, no browser required for
the default provider set. Dockerfile included; GitHub Actions CI runs the full test suite on
3.10–3.13. For read-only filesystems point IMGAGENT_WORKSPACE at a writable path — imgagent
detects and warns before work is lost.
Development
pip install -e '.[dev]'
pytest # unit suite (mock servers, no network)
pytest -m integration # opt-in live-source tests
ruff check src tests
Authors & owners
- superz1402 — author, owner
- Bilal140202 — author, owner
- ansaribilal14 — author, owner
- hamza140202 — author, owner
License & attribution
MIT — see LICENSE. imgagent was built as an independent implementation; it studies the architecture of projects like gallery-dl (GPL) and img2dataset (Apache-2.0) without copying their code. Downloaded images carry their own licenses — the manifest records them; you are responsible for respecting them at publication time.
Metadata
Release files for imgagent 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imgagent-0.1.2.tar.gz | 75.9 kB | Without provenance | Details for imgagent-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imgagent-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for imgagent-0.1.2-py3-none-any.whl |
Total release size: 142.9 kB
Release files / imgagent-0.1.2.tar.gz
| Download URL | imgagent-0.1.2.tar.gz |
|---|---|
| Size | 75.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a10bd18dfcb40a4cc4abfaa4bcd84a4fc62c3eb7b84a897ca23fd934d40b9aba
|
|
BLAKE2b-256 checksum How to use checksums |
44e30ffbccd02a640a3d5dfddc64f1f719ec96e7430eac513824c13437ac47b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / imgagent-0.1.2-py3-none-any.whl
| Download URL | imgagent-0.1.2-py3-none-any.whl |
|---|---|
| Size | 67.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a90678c96ffa9eb295c67ffdf9d79399879f236fa21be4a671a8b5da68192e8
|
|
BLAKE2b-256 checksum How to use checksums |
a6747c397193bdac3638dbbe7ae09259a3f5d824ab17c3464f34d23730bf0ed9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for imgagent 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.