Skip to content

Barcode

Read barcodes and QR codes from images, identify their symbology, and generate new ones as PNGs

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/barcode/index.md to help me query Barcode with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Fan one image out into every symbol it contains, one row each.

Example output · captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq
Result
seq format text
0 QR_CODE multi

Quick start

Choose where to run Barcode, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.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;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'barcode' AS barcode (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-barcode'
);

3. Run a query

query.sql
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'barcode' AS barcode (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Barcode and QR-code decoding and generation over Apache Arrow.

Catalog

Everything barcode exposes once attached — read straight from the worker's released build.

barcode 1 schema
main 1 table · 5 functions

Barcode / QR-code decode and generation functions.

Schema examples (9)
Examples (9)

Round-trip: encode text as a QR image, then decode it back to a string.

SELECT barcode.main.decode_barcode(barcode.main.generate_qr('hello world')) AS decoded;

Detect the symbology of the first barcode/QR in a generated image.

SELECT barcode.main.barcode_format(barcode.main.generate_qr('hello world')) AS format;

Encode a URL as a QR-code PNG image (returns a BLOB).

SELECT barcode.main.generate_qr('https://query.farm') AS qr_png;

Encode an EAN-13 product code as a barcode PNG image.

SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') AS ean13_png;
5 more examples

List every supported symbology name, alphabetically.

SELECT format FROM barcode.main.barcode_formats ORDER BY format;

Fan one image out into every symbol it contains, one row each.

SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq;
Result
seq format text
0 QR_CODE multi

Label QA: print EAN-13 barcodes for a list of SKUs, scan each image back, and flag any that do not round-trip (a leading-zero EAN-13 reads back as its 12-digit UPC_A).

SELECT sku, barcode.main.barcode_format(png) AS format,
  barcode.main.decode_barcode(png) AS decoded,
  barcode.main.decode_barcode(png) = sku AS round_trips
FROM (SELECT sku, barcode.main.generate_barcode(sku, 'EAN_13') AS png FROM (VALUES ('5901234123457'), ('4006381333931'), ('0036000291452')) AS t(sku))
ORDER BY sku;

Relabel a product: read the code off its EAN-13 barcode, encode a product-page URL built from it as a QR code, and decode every symbol in the new QR image to verify it.

SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('https://shop.example/p/' || barcode.main.decode_barcode(barcode.main.generate_barcode('4006381333931', 'EAN_13'))))
ORDER BY seq;

Symbology coverage: detect the format of each image in a label set and count labels per supported symbology, listing unused symbologies with 0.

WITH labels AS (SELECT barcode.main.generate_qr(t.ticket) AS png FROM (VALUES ('ticket-001'), ('ticket-002')) AS t(ticket) UNION ALL SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') UNION ALL SELECT barcode.main.generate_barcode('PALLET-77', 'CODE_128')) SELECT f.format, count(l.png) AS labels
FROM barcode.main.barcode_formats AS f
LEFT JOIN labels AS l ON barcode.main.barcode_format(l.png) = f.format
GROUP BY f.format
ORDER BY labels DESC, f.format;
Tables
barcode_formats 3 examples1 col

Supported barcode/QR symbology names, one per row.

Columns
formatnot null VARCHAR
A supported barcode/QR symbology name in canonical ZXing form, e.g. QR_CODE, EAN_13, CODE_128 — valid as the `format` argument to generate_barcode.
ConstraintsPRIMARY KEY (format)
Examples (3)

Count how many barcode/QR symbologies this worker supports.

SELECT count(*) AS supported_formats FROM barcode.main.barcode_formats;

List the Code-family symbologies (CODE_39/93/128) alphabetically.

SELECT format
FROM barcode.main.barcode_formats
WHERE format LIKE 'CODE%'
ORDER BY format;

Symbology coverage: detect the format of each image in a label set and count labels per supported symbology, listing unused symbologies with 0.

WITH labels AS (SELECT barcode.main.generate_qr(t.ticket) AS png FROM (VALUES ('ticket-001'), ('ticket-002')) AS t(ticket) UNION ALL SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') UNION ALL SELECT barcode.main.generate_barcode('PALLET-77', 'CODE_128')) SELECT f.format, count(l.png) AS labels
FROM barcode.main.barcode_formats AS f
LEFT JOIN labels AS l ON barcode.main.barcode_format(l.png) = f.format
GROUP BY f.format
ORDER BY labels DESC, f.format;
Link
Scalar functions
barcode_format (blob BLOB) 1 example

Format name of the first barcode/QR in an image BLOB, e.g. QR_CODE (NULL if none)

Arguments
blob BLOB
Raw bytes of an image (PNG/JPEG/GIF/BMP/WebP) to scan for a barcode/QR code
ReturnsVARCHAR
Example

Identify the symbology of the first barcode/QR in an image (e.g. 'QR_CODE').

SELECT barcode.main.barcode_format(barcode.main.generate_qr('hello world'));
Link
decode_barcode (blob BLOB) 1 example

Decode the first barcode/QR in an image BLOB to its text (NULL if none)

Arguments
blob BLOB
Raw bytes of an image (PNG/JPEG/GIF/BMP/WebP) to scan for a barcode/QR code
ReturnsVARCHAR
Example

Decode the text of the first barcode/QR in an image (here a freshly generated QR).

SELECT barcode.main.decode_barcode(barcode.main.generate_qr('hello world'));
Link
generate_barcode (text VARCHAR, format ANY, size_px ANY) +1 overload 3 examples

Generate a barcode PNG (BLOB) for the given text in a named symbology at the default size

Arguments
text VARCHAR
Payload to encode into the barcode (must be valid for the chosen symbology, e.g. 13 digits for EAN_13)
format ANY
Canonical symbology name to encode in, e.g. QR_CODE, EAN_13, CODE_128
size_px ANY
Width in pixels of the output image (default 256)
Overloads
generate_barcode(text VARCHAR, format ANY) → BLOBgenerate_barcode(text VARCHAR, format ANY, size_px ANY) → BLOB
ReturnsBLOB
Examples (3)

Encode text as a default-size Code 128 barcode PNG.

SELECT barcode.main.generate_barcode('CODE128', 'CODE_128');

Encode an EAN-13 product code as a 600-pixel-wide barcode PNG.

SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13', 600);

Label QA: print EAN-13 barcodes for a list of SKUs, scan each image back, and flag any that do not round-trip (a leading-zero EAN-13 reads back as its 12-digit UPC_A).

SELECT sku, barcode.main.barcode_format(png) AS format,
  barcode.main.decode_barcode(png) AS decoded,
  barcode.main.decode_barcode(png) = sku AS round_trips
FROM (SELECT sku, barcode.main.generate_barcode(sku, 'EAN_13') AS png FROM (VALUES ('5901234123457'), ('4006381333931'), ('0036000291452')) AS t(sku))
ORDER BY sku;
Link
generate_qr (text VARCHAR, size_px ANY) +1 overload 2 examples

Generate a QR-code PNG (BLOB) for the given text at the default size

Arguments
text VARCHAR
Arbitrary text to encode into the QR code — for example a website link.
size_px ANY
Square side length in pixels of the output image (default 256)
Overloads
generate_qr(text VARCHAR) → BLOBgenerate_qr(text VARCHAR, size_px ANY) → BLOB
ReturnsBLOB
Examples (2)

Encode a URL as a default-size QR-code PNG.

SELECT barcode.main.generate_qr('https://query.farm');

Encode a URL as a 512x512-pixel QR-code PNG.

SELECT barcode.main.generate_qr('https://query.farm', 512);
Link
Table functions
decode_barcodes (blob BLOB) 3 examples

Decode ALL barcodes/QR codes in an image BLOB into (seq, format, text) rows

Arguments
blob BLOB
Raw bytes of a single image to scan for every barcode/QR code it contains
Returns columns
seq BIGINT
Zero-based index of the symbol within the image, in detection order.
format VARCHAR
Detected symbology name in canonical ZXing form, e.g. QR_CODE, EAN_13, CODE_128.
text VARCHAR
Decoded payload text of the symbol.
Examples (3)

Relabel a product: read the code off its EAN-13 barcode, encode a product-page URL built from it as a QR code, and decode every symbol in the new QR image to verify it.

SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('https://shop.example/p/' || barcode.main.decode_barcode(barcode.main.generate_barcode('4006381333931', 'EAN_13'))))
ORDER BY seq;

Decode every symbol in a freshly generated QR image.

SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('hello world'))
ORDER BY seq;
SELECT format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_barcode('5901234123457', 'EAN_13'));
Link

Try these queries

Round-trip: encode text as a QR image, then decode it back to a string.

SELECT barcode.main.decode_barcode(barcode.main.generate_qr('hello world')) AS decoded

Uses decode_barcodegenerate_qr

Detect the symbology of the first barcode/QR in a generated image.

SELECT barcode.main.barcode_format(barcode.main.generate_qr('hello world')) AS format

Uses barcode_formatgenerate_qr

Encode a URL as a QR-code PNG image (returns a BLOB).

SELECT barcode.main.generate_qr('https://query.farm') AS qr_png

Uses generate_qr

Encode an EAN-13 product code as a barcode PNG image.

SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') AS ean13_png

Uses generate_barcode

List every supported symbology name, alphabetically.

SELECT format FROM barcode.main.barcode_formats ORDER BY format

Uses barcode_formats

Relabel a product: read the code off its EAN-13 barcode, encode a product-page URL built from it as a QR code, and decode every symbol in the new QR image to verify it.

SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('https://shop.example/p/' || barcode.main.decode_barcode(barcode.main.generate_barcode('4006381333931', 'EAN_13'))))
ORDER BY seq

Uses decode_barcodesgenerate_qrdecode_barcodegenerate_barcode

12 more examples in the Catalog, each listed under the table or function it uses.

Barcode is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.