# Image

> Decode images, read EXIF and GPS tags, spot near-duplicates by perceptual hash, and make thumbnails

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/image.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `img`. Release: [v0.5.0](https://github.com/Query-farm/vgi-image/releases/tag/v0.5.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-image) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=image). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

No service credentials are declared by this connector. Individual datasets, input files or deployments may have their own prerequisites.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### From GitHub

Attach the release directly

Uses the verified release each time you attach the connector.

```sql
ATTACH 'img' AS img (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-image@v0.5.0'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'img' AS img (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-image:0.5.0'
);
```

## See what you can query

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
WITH images(name, data) AS (SELECT 'a.png', from_hex('89504e470d0a1a0a0000000d4948445200000002000000020802000000fdd49a73000000164944415478da6360608812608862601088121088020009be01a9f633974e0000000049454e44ae426082') UNION ALL SELECT 'b.png', from_hex('89504e470d0a1a0a0000000d4948445200000004000000040802000000269309290000002e4944415478da1d864901003008c3f246045ad0819acac355c778e4c0c0e1efaba4aa22a627ba6332130bb4f2de03fd2e1413e2c4ad370000000049454e44ae426082') UNION ALL SELECT 'a_copy.bmp', img.main.convert(from_hex('89504e470d0a1a0a0000000d4948445200000002000000020802000000fdd49a73000000164944415478da6360608812608862601088121088020009be01a9f633974e0000000049454e44ae426082'), 'bmp')), hashed AS (SELECT name, img.main.phash(data) AS h FROM images) SELECT x.name AS image, y.name AS other, img.main.phash_distance(x.h, y.h) AS distance FROM hashed x JOIN hashed y ON x.name < y.name ORDER BY distance, image, other;
```

- [img.main.convert — scalar_function](https://query.farm/products/orchard/connectors/image/objects/scalar_function.bWFpbg.Y29udmVydA.md): exact declaration for this example.
- [img.main.phash — scalar_function](https://query.farm/products/orchard/connectors/image/objects/scalar_function.bWFpbg.cGhhc2g.md): exact declaration for this example.
- [img.main.phash_distance — scalar_function](https://query.farm/products/orchard/connectors/image/objects/scalar_function.bWFpbg.cGhhc2hfZGlzdGFuY2U.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:21:29+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.5.0",
  "sample": {
    "columns": [
      "image",
      "other",
      "distance"
    ],
    "types": [
      "VARCHAR",
      "VARCHAR",
      "INTEGER"
    ],
    "rows": [
      [
        "a.png",
        "a_copy.bmp",
        0
      ],
      [
        "a.png",
        "b.png",
        17
      ],
      [
        "a_copy.bmp",
        "b.png",
        17
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### image — Image Inspection, EXIF/GPS, Perceptual Hashing & Thumbnails in SQL

![image logo](https://avatars.githubusercontent.com/u/49300799?s=240&v=4)

Decode images, read EXIF and GPS metadata, compute perceptual hashes for near-duplicate detection, and generate thumbnails directly in DuckDB SQL — no external tooling or file wrangling required. The `image` worker brings a full image-processing toolbox to the `img` catalog, turning ordinary `BLOB` columns of PNG, JPEG, GIF, BMP, TIFF and WebP bytes into queryable, structured data.

This extension is for anyone cataloguing, deduplicating, or auditing image collections from SQL: data engineers building media pipelines, analysts hunting near-duplicate or geotagged photos, and teams that want EXIF and perceptual-hash features right next to their existing DuckDB tables. Everything runs in-process over Apache Arrow, so image-derived columns join against the rest of your data without ever leaving the database.

## How it works

The worker is powered by the pure-Rust [`image`](https://github.com/image-rs/image) crate ([docs](https://docs.rs/image)) for decoding, resizing and format conversion; [`kamadak-exif`](https://github.com/kamadak/exif-rs) ([docs](https://docs.rs/kamadak-exif)) for parsing EXIF tags and GPS coordinates; and [`image_hasher`](https://github.com/abonander/img_hash) ([docs](https://docs.rs/image_hasher)) for 64-bit perceptual hashes. Image bytes are passed as DuckDB `BLOB` values and `NULL` inputs flow through to `NULL` results, so the capabilities compose cleanly inside larger queries.

## When to reach for it

Reach for this worker to catalogue a folder of images by their format and dimensions, to read capture metadata and geotags for auditing or mapping, to find near-duplicate or reposted photos by perceptual similarity, and to normalize or preview a mixed set of images — all without leaving SQL or standing up an external image-processing service. Malformed or truncated bytes yield a graceful `NULL` or a clear error, so it is safe to run across messy data at scale.

## Find the exact SQL object

[Browse 10 object declarations](https://query.farm/products/orchard/api/v1/connectors/image/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=image&q=img).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-image",
  "harvest": {
    "status": "ok",
    "method": "github-auto",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 6,
    "passed": 6,
    "failed": 0,
    "needs_credentials": 0,
    "location": "github-auto://Query-farm/vgi-image@v0.5.0",
    "transport": "github-auto",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:17:00+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
