Reading QR Codes
read · detect
Find and decode every QR code in a PNG, a JPEG or a raw pixel buffer — rotated, tilted, mirrored, inverted or damaged — and get the text, the bytes, the position and the encoding details back as JSON.
read
Decode every symbol in an image
read finds and decodes every QR Code (Model 2, versions 1–40) in one image. The request names the image in source; everything else is optional. The response has one entry of results[] for each symbol. An image without a symbol is not an error: the method returns true and results[] is empty.
// Read every QR code in an image file
Chilkat.JsonObject jsonIn = new Chilkat.JsonObject();
jsonIn.UpdateString("source.path", "photo.jpg");
Chilkat.JsonObject jsonOut = new Chilkat.JsonObject();
Chilkat.Formats fmt = new Chilkat.Formats();
bool success = fmt.QrCode("read", jsonIn, jsonOut);
if (!success) {
Console.WriteLine(jsonOut.StringOf("errors[0].code") + ": " + jsonOut.StringOf("errors[0].message"));
Console.WriteLine(fmt.LastErrorText);
return;
}
// One entry of results[] per symbol. Finding none is not an error: the array is empty.
int n = jsonOut.SizeOfArray("results");
for (int i = 0; i < n; i++) {
jsonOut.I = i;
Console.WriteLine(jsonOut.StringOf("results[i].text"));
Console.WriteLine(" version " + jsonOut.IntOf("results[i].metadata.version")
+ ", level " + jsonOut.StringOf("results[i].metadata.errorCorrection")
+ ", turned " + jsonOut.IntOf("results[i].geometry.rotation") + " degrees"
+ ", first corner at " + jsonOut.StringOf("results[i].geometry.polygon[0].x")
+ ", " + jsonOut.StringOf("results[i].geometry.polygon[0].y"));
}// Read every QR code in an image file
CkJsonObject jsonIn;
jsonIn.UpdateString("source.path", "photo.jpg");
CkJsonObject jsonOut;
CkFormats fmt;
bool success = fmt.QrCode("read", jsonIn, jsonOut);
if (!success) {
std::cout << jsonOut.stringOf("errors[0].code") << ": " << jsonOut.stringOf("errors[0].message") << "\r\n";
std::cout << fmt.lastErrorText() << "\r\n";
return;
}
// One entry of results[] per symbol. Finding none is not an error: the array is empty.
int n = jsonOut.SizeOfArray("results");
for (int i = 0; i < n; i++) {
jsonOut.put_I(i);
std::cout << jsonOut.stringOf("results[i].text") << "\r\n";
std::cout << " version " << jsonOut.IntOf("results[i].metadata.version");
std::cout << ", level " << jsonOut.stringOf("results[i].metadata.errorCorrection");
std::cout << ", turned " << jsonOut.IntOf("results[i].geometry.rotation") << " degrees";
std::cout << ", first corner at " << jsonOut.stringOf("results[i].geometry.polygon[0].x");
std::cout << ", " << jsonOut.stringOf("results[i].geometry.polygon[0].y") << "\r\n";
}import chilkat2
# Read every QR code in an image file
jsonIn = chilkat2.JsonObject()
jsonIn.UpdateString("source.path", "photo.jpg")
jsonOut = chilkat2.JsonObject()
fmt = chilkat2.Formats()
success = fmt.QrCode("read", jsonIn, jsonOut)
if not success:
print(jsonOut.StringOf("errors[0].code") + ": " + jsonOut.StringOf("errors[0].message"))
print(fmt.LastErrorText)
exit()
# One entry of results[] per symbol. Finding none is not an error: the array is empty.
n = jsonOut.SizeOfArray("results")
for i in range(n):
jsonOut.I = i
print(jsonOut.StringOf("results[i].text"))
print(" version", jsonOut.IntOf("results[i].metadata.version"),
"level", jsonOut.StringOf("results[i].metadata.errorCorrection"),
"turned", jsonOut.IntOf("results[i].geometry.rotation"), "degrees,",
"first corner at", jsonOut.StringOf("results[i].geometry.polygon[0].x"),
jsonOut.StringOf("results[i].geometry.polygon[0].y"))Formats, have the same methods and the same JSON requests in every supported language: C, C++, C#, VB.NET, Java, Objective-C, Swift, Python, PHP, Perl, Ruby, Node.js, Electron, React Native, Dart / Flutter, Go, Rust, Zig, Delphi, C++Builder, Free Pascal / Lazarus, Classic ASP, VB6, VBScript, FoxPro, DataFlex, PowerBuilder, Xojo, Xbase++, PureBasic, AutoIt, B4A / B4J, LabVIEW, SQL Server and Tcl. See Chilkat Downloads for Every Language.

geometry.polygon in orange, its corners numbered in the order they are returned, and geometry.bounds in blue.The request, as JSON
A read request has no symbology and no payload. Its groups are source, reader, results, parse and limits; unknown members are rejected with unknownOption.
{ "source": { "path": "photo.jpg" } }The response
This is the complete response for the image above. The symbol was located through the perspective, and its content, version, error-correction level and mask were recovered.
{
"image": { "width": 640, "height": 480, "format": "jpeg" },
"results": [
{
"symbology": "qr", "frame": 0, "id": 0, "byteCount": 52,
"text": "https://www.chilkatsoft.com/refdoc/csFormatsRef.html", "textStatus": "valid",
"charset": "utf-8", "charsetSource": "utf8Detected",
"bytesBase64": "aHR0cHM6Ly93d3cuY2hpbGthdHNvZnQuY29tL3JlZmRvYy9jc0Zvcm1hdHNSZWYuaHRtbA==",
"geometry": {
"bounds": { "x": 193.63, "y": 97.03, "width": 263.94, "height": 226.8 },
"polygon": [
{ "x": 243.25, "y": 97.03 }, { "x": 457.57, "y": 142.47 },
{ "x": 418, "y": 323.83 }, { "x": 193.63, "y": 269.49 }
],
"rotation": 12, "moduleSize": 5.53, "mirrored": false, "inverted": false
},
"metadata": { "version": 5, "errorCorrection": "Q", "mask": 6 }
}
],
"errors": [], "warnings": []
}| Group | Purpose | Documented |
|---|---|---|
source | The image: a PNG or JPEG file, the bytes of one, or raw pixels. | Sources |
reader | How hard to look, where, and how many symbols to return. | Reader options |
results | What each result carries: bytes, geometry, metadata, segments, diagnostics, crops. | Results |
parse | Interpret the content of each symbol as a URL, Wi-Fi configuration, email, … | Structured Payloads |
limits | timeoutMs and maxPixels. | Limits and errors |
source
Where the image comes from
Exactly one of source.path, source.base64 and source.pixels says where the image is. The same source group is used by read, detect and extract.
| Member | Values | Default | Notes |
|---|---|---|---|
source.path | string | — | The path of a PNG or JPEG file. A file that is missing, empty or cannot be read fails with inputFailed at /source/path. |
source.base64 | base64 string | — | The bytes of a PNG or JPEG file (up to 256 MiB decoded). |
source.pixels | object | — | Raw pixels: base64, width, height (1–32,768) and format are required; stride (bytes per row) is optional. Rows run top to bottom, and the data must be exactly height × stride bytes. |
source.pixels.format | "gray8" · "rgb24" · "rgba32" · "bgra32" | required | One, three or four bytes per pixel. Alpha is straight (not premultiplied). |
source.pixels.stride | integer | width × bytes per pixel | Give it when rows are padded. Absent or 0 means the rows are tight. |
source.format | "auto" · "png" · "jpeg" | "auto" | For a file or base64 source. auto goes by the first bytes of the data. Naming a format asserts it: data that is something else is invalidImage. Not applicable to raw pixels. |
source.alphaBackground | "#RRGGBB" | "#FFFFFF" | The color placed under transparent pixels before the image is searched. |
source.applyExifOrientation | bool | true | Turn a JPEG as its Exif Orientation tag says before searching it. See Exif orientation. |
source.frames | — | — | Reserved for multi-frame images (unsupportedFeature). |
{ "source": { "base64": "iVBORw0KGgoAAAANSUhEUgAAAJQAAACU..." } }{ "source": { "pixels": { "base64": "/////////////////////w...",
"width": 148, "height": 148, "format": "gray8" } } }// The image file is already in memory (downloaded, read from a database, ...)
Chilkat.BinData image = new Chilkat.BinData();
image.LoadFile("photo.jpg");
Chilkat.JsonObject jsonIn = new Chilkat.JsonObject();
jsonIn.UpdateString("source.base64", image.GetEncoded("base64"));
// Or: raw pixels. Here frame holds an 8-bit gray camera image of 640 x 480 (307,200 bytes).
Chilkat.JsonObject jsonIn2 = new Chilkat.JsonObject();
jsonIn2.UpdateString("source.pixels.base64", frame.GetEncoded("base64"));
jsonIn2.UpdateInt("source.pixels.width", 640);
jsonIn2.UpdateInt("source.pixels.height", 480);
jsonIn2.UpdateString("source.pixels.format", "gray8");
Chilkat.JsonObject jsonOut = new Chilkat.JsonObject();
bool success = fmt.QrCode("read", jsonIn, jsonOut);// The image file is already in memory (downloaded, read from a database, ...)
CkBinData image;
image.LoadFile("photo.jpg");
CkJsonObject jsonIn;
jsonIn.UpdateString("source.base64", image.getEncoded("base64"));
// Or: raw pixels. Here frame holds an 8-bit gray camera image of 640 x 480 (307,200 bytes).
CkJsonObject jsonIn2;
jsonIn2.UpdateString("source.pixels.base64", frame.getEncoded("base64"));
jsonIn2.UpdateInt("source.pixels.width", 640);
jsonIn2.UpdateInt("source.pixels.height", 480);
jsonIn2.UpdateString("source.pixels.format", "gray8");
CkJsonObject jsonOut;
bool success = fmt.QrCode("read", jsonIn, jsonOut);# The image file is already in memory (downloaded, read from a database, ...)
image = chilkat2.BinData()
image.LoadFile("photo.jpg")
jsonIn = chilkat2.JsonObject()
jsonIn.UpdateString("source.base64", image.GetEncoded("base64"))
# Or: raw pixels. Here frame holds an 8-bit gray camera image of 640 x 480 (307,200 bytes).
jsonIn2 = chilkat2.JsonObject()
jsonIn2.UpdateString("source.pixels.base64", frame.GetEncoded("base64"))
jsonIn2.UpdateInt("source.pixels.width", 640)
jsonIn2.UpdateInt("source.pixels.height", 480)
jsonIn2.UpdateString("source.pixels.format", "gray8")
jsonOut = chilkat2.JsonObject()
success = fmt.QrCode("read", jsonIn, jsonOut)Formats, have the same methods and the same JSON requests in every supported language: C, C++, C#, VB.NET, Java, Objective-C, Swift, Python, PHP, Perl, Ruby, Node.js, Electron, React Native, Dart / Flutter, Go, Rust, Zig, Delphi, C++Builder, Free Pascal / Lazarus, Classic ASP, VB6, VBScript, FoxPro, DataFlex, PowerBuilder, Xojo, Xbase++, PureBasic, AutoIt, B4A / B4J, LabVIEW, SQL Server and Tcl. See Chilkat Downloads for Every Language.The response names what was read in image: width, height, format (png, jpeg or pixels) and, when the file states a resolution (a PNG pHYs chunk in metres, a JFIF density), dpi.
PNG
Every color type and bit depth is read: grayscale, truecolor and palette images, with or without alpha or a transparency chunk, 1 to 16 bits per sample. Reading is strict. A file with a wrong signature, a failed CRC, chunks out of order or damaged image data is refused with invalidImage at /source, and so is a file with data after its end. Interlaced PNG, animated PNG (APNG) and a file with an unknown critical chunk are refused with unsupportedFeature.
JPEG
Baseline, extended sequential and progressive JPEG with 8-bit samples are read, in grayscale or YCbCr color, with any chroma subsampling in which every component's sampling factor divides the largest (4:4:4, 4:2:2, 4:2:0, 4:4:0, 4:1:1 and others), with or without restart intervals.
| Response | When |
|---|---|
unsupportedFeature at /source | A valid JPEG outside that subset: 12-bit samples, arithmetic coding, lossless or hierarchical JPEG, two or four components (CMYK, YCCK), RGB stored without a color transform, sampling factors that are not whole multiples of each other. |
invalidImage at /source | Anything malformed or truncated. The decoder is strict and never returns a partial image. One deliberate leniency: bytes after the end-of-image marker are ignored, because cameras and phones append data there. |
Exif orientation
A camera often stores a portrait photograph as landscape pixels plus an Exif Orientation tag that tells a viewer how to turn it. With source.applyExifOrientation true (the default) and a tag of 2 to 8, the image is turned first, so that image.width and image.height, reader.region and every coordinate in the response refer to the image as it is shown. The response reports the tag in image.exifOrientation and what was done in image.orientationApplied.
{
"image": { "width": 640, "height": 480, "format": "jpeg", "exifOrientation": 6, "orientationApplied": true },
"results": [ { ..., "geometry": { ..., "rotation": 12, ... } } ],
...
}{
"image": { "width": 480, "height": 640, "format": "jpeg", "exifOrientation": 6, "orientationApplied": false },
"results": [ { ..., "geometry": { ..., "rotation": 282, ... } } ],
...
}Orientations 2, 4, 5 and 7 show a mirror image, so a symbol in such a file is reported with mirrored: true. An Exif block that cannot be parsed, or an orientation outside 1 to 8, is ignored: there is then no exifOrientation member, and no error. PNG files and raw pixels carry no orientation.
limits.maxPixels (default 16,777,216) bounds the width × height of the decoded image, and it is checked before memory is allocated. A larger image fails with resourceLimit at /source. See Limits and errors.reader
How hard to look, and where
The reader group controls the search. The defaults suit most images: the reader looks for dark-on-light and light-on-dark symbols, upright or turned, mirrored or not, at full size and on reduced copies of large images.
| Member | Values | Default | Notes |
|---|---|---|---|
reader.symbologies | array of symbology IDs | all that can be read | Only "qr" can be read in v11.8.0. An unknown ID is invalidEnum; a known symbology that cannot be read yet ("microQr") is unsupportedFeature; a symbology outside the QR family given to QrCode is optionNotApplicable. The path names the entry: /reader/symbologies/0. |
reader.profile | "fast" · "balanced" · "thorough" | "balanced" | fast uses one global threshold. balanced adds a local (adaptive) threshold and, for images of 1000 px or more, copies reduced to a half and a quarter. thorough adds a second local window and always tries the reduced copies. |
reader.region | { x, y, width, height, units } | the whole image | Search only this rectangle. units is "pixels" (default) or "normalized" (fractions of the image, 0 to 1). The rectangle must lie inside the image (outOfRange otherwise). Coordinates in the response stay those of the full image. |
reader.maxResults | 1–4096 | 100 | Stop after this many symbols. Reaching it is success, with "stopReason": "maxResults" in the response. |
reader.expectedCount | 1–maxResults | — | Stop as soon as this many symbols are decoded: the fastest way to read an image known to hold one symbol. Also reported as "stopReason": "maxResults". |
reader.tryInvert | bool | true | Also read light-on-dark symbols. |
reader.tryMirror | bool · "auto" | "auto" | Also try the mirror image of each candidate. auto is the same as true. |
reader.tryDownscale | bool | true | Allow the reduced copies of the profile. |
reader.tryRotate | bool | true | Accepted for uniformity with other symbologies. QR Codes are found at any angle whatever its value. |
reader.allowDamaged | bool | true | false keeps only the symbols that needed no error correction at all. |
reader.fallbackCharset | charset name | "iso-8859-1" | The charset of byte data that is not UTF-8 and has no ECI. See Text and bytes. |
reader.assembleStructuredAppend | bool | true | Combine the symbols of a structured-append set in assemblies[]. |
reader.pureSymbolreader.dpmreader.checksum | false"off""require" | as shown | Reserved. Only the values shown are accepted. |
Several symbols, in any state
An image may hold many symbols, and they need not look alike. The four below are read with the default settings:

id | text | bounds x, y | rotation | mirrored | inverted |
|---|---|---|---|---|---|
| 0 | https://www.chilkatsoft.com | 44, 36 | 0° | false | false |
| 1 | WIFI:T:WPA;S:Chilkat Guest;P:correct\;horse;; | 240, 36 | 0° | false | false |
| 2 | INVERTED: light on dark | 52, 240 | 0° | false | true |
| 3 | tel:+1-202-555-0143 | 256, 240 | 270° | true | false |
Results are in position order: by the top edge of the bounding box, then by its left edge, so symbols printed in one row stay in left-to-right order. id is the index in that order. With "tryInvert": false and "tryMirror": false the same image gives 2 results: the light-on-dark and the mirrored symbol are no longer looked for.
Reading part of an image
reader.region restricts the search, which is faster and lets you address one area of a form or a label. This request reads the top right quarter of the sheet:
{
"source": { "path": "sheet.png" },
"reader": {
"region": { "x": 0.5, "y": 0, "width": 0.5, "height": 0.5, "units": "normalized" }
}
}It returns one result, WIFI:T:WPA;S:Chilkat Guest;P:correct\;horse;;, with its bounds at x: 240, y: 36 — full-image coordinates, not coordinates within the region.
Stopping early
When you know how many symbols the image holds, say so. The search ends as soon as that many are decoded:
{ "source": { "path": "sheet.png" }, "reader": { "expectedCount": 1 } }{
"image": { "width": 408, "height": 408, "format": "png" },
"results": [ { "symbology": "qr", "frame": 0, "id": 0, "text": "https://www.chilkatsoft.com", ... } ],
"stopReason": "maxResults",
"errors": [], "warnings": []
}reader.region. Remember to raise reader.maxResults above its default of 100.results
What each result carries
The results group selects what each entry of results[] carries. Leave out what you do not need: a response without bytes and geometry is smaller and quicker to walk.
| Member | Default | Adds to each result |
|---|---|---|
results.includeBytes | true | bytesBase64: the payload bytes. |
results.includeGeometry | true | geometry: where the symbol is. |
results.includeMetadata | true | metadata: version, error-correction level, mask, ECI, FNC1, structured append. |
results.includeSegments | false | segments[]: how the data was encoded, segment by segment. |
results.includeDiagnostics | false | diagnostics: how much error correction was needed. |
results.includeCrops | false | crop: a PNG image of the symbol, cut from the source. See Extract. |
results.order | "position" | The order of results[]. position is the only value. |
The members of a result
| Member | Meaning |
|---|---|
symbology | Always "qr" in v11.8.0. |
id | The index of the result, in position order. Other parts of the response refer to a symbol by it. |
frame | Always 0 (reserved for multi-frame sources). |
byteCount | The number of payload bytes. |
texttextStatus | The payload as text (UTF-8 in the JSON), when textStatus is "valid". See Text and bytes. |
charsetcharsetSource | The charset the bytes were taken to be in, and how that was decided. |
bytesBase64 | The payload bytes: the logical content, never raw codewords. Kanji and Hanzi characters are their Shift-JIS and GB2312 byte pairs. |
geometry.bounds | { x, y, width, height }: the upright bounding box of the symbol, without quiet zone. |
geometry.polygon | The four corners of the symbol, without quiet zone, in the symbol's own order: the corners at its top-left, top-right and bottom-right, then bottom-left, as the symbol was printed. For a turned or mirrored symbol they are therefore not in the image's clockwise-from-top-left order. |
geometry.rotation | The clockwise angle of the symbol's top edge, 0 to 359 degrees. |
geometry.moduleSize | Pixels per module. |
geometry.mirroredgeometry.inverted | Whether the symbol is a mirror image; whether it is light on dark. |
metadata.versionmetadata.errorCorrectionmetadata.mask | The QR version (1–40), the level ("L", "M", "Q", "H") and the mask pattern (0–7) of the symbol. |
metadata.eci | When the symbol has ECI designators: their values, in the order they occur. |
metadata.fnc1metadata.fnc1ApplicationIndicator | When the symbol is in FNC1 mode: "first" (GS1) or "second" (with the application indicator). |
metadata.structuredAppend | When the symbol is part of a set: { index, total, parity }. See structured append. |
parseStatusparsed | With "parse": { "enabled": true }: the content interpreted as a structured payload. |
x: 24. Values are written with at most two decimals.Text and bytes
A QR symbol holds bytes; whether they are text, and in which charset, is partly a matter of convention. The reader always returns the bytes, and returns text when it can be sure of it. A failure to make text is never a failure to decode.
charsetSource | How the charset was decided |
|---|---|
"eci" | The symbol states its charset with an ECI designator. |
"utf8Detected" | No ECI, and the bytes are well-formed UTF-8: they are taken as UTF-8. This is what nearly every QR code in use today holds. |
"fallback" | No ECI, and the bytes are not UTF-8: they are read in reader.fallbackCharset (default ISO-8859-1, the default of the QR standard). |
"mixed" | Different parts of the symbol are in different charsets. |
"none" | Digits or alphanumeric data only: no charset is involved. |
textStatus | Meaning |
|---|---|
"valid" | text is present. |
"invalid" | The bytes are not valid in their stated or assumed charset. There is no text. |
"unavailable" | The symbol declares binary data or an unknown ECI, or the text would contain the character U+0000. There is no text. |
{
"symbology": "qr", "frame": 0, "id": 0, "byteCount": 11, "text": "Café Zürich",
"textStatus": "valid", "charset": "iso-8859-1", "charsetSource": "fallback",
"bytesBase64": "Q2Fm6SBa/HJpY2g="
}{
"symbology": "qr", "frame": 0, "id": 0, "byteCount": 17, "text": "Grüße aus Köln",
"textStatus": "valid", "charset": "utf-8", "charsetSource": "eci",
"metadata": { "version": 2, "errorCorrection": "M", "mask": 0, "eci": [ 26 ] },
"segments": [ { "mode": "byte", "byteOffset": 0, "byteCount": 17, "eci": 26 } ]
}{
"symbology": "qr", "frame": 0, "id": 0, "byteCount": 9, "textStatus": "unavailable",
"charset": "iso-8859-1", "charsetSource": "fallback", "bytesBase64": "AAEC+vv8/f7/"
}reader.fallbackCharset accepts utf-8, us-ascii, iso-8859-1 to iso-8859-16, windows-1250 to windows-1258, shift_jis, gb2312, big5, euc-kr and cp437. The ECI values understood are 0 to 13, 15 to 18 and 20 to 30 (character sets) and 899 (binary).
Segments and diagnostics
segments[] lists the data segments of the symbol in order: mode (numeric, alphanumeric, byte, kanji or hanzi), the byteOffset and byteCount of its bytes within the payload, and its eci when one applies. diagnostics reports correctedCodewords (the number of codewords the Reed-Solomon error correction had to repair) and formatBitErrors (the number of wrong bits in the format information): a simple measure of how clean the symbol was.
{
"segments": [ { "mode": "byte", "byteOffset": 0, "byteCount": 52 } ],
"diagnostics": { "correctedCodewords": 0, "formatBitErrors": 0 }
}structured append
Messages split across several symbols
A structured-append set is one message split across up to 16 symbols. Each symbol is an ordinary result, with metadata.structuredAppend giving its index (from 0), the total and the parity byte of the whole message. When all the symbols of a set are in the image, assemblies[] gives the message whole.

{
"image": { "width": 436, "height": 152, "format": "png" },
"results": [
{
"symbology": "qr", "frame": 0, "id": 0, "byteCount": 23,
"text": " back together by read.", "textStatus": "valid", "charset": "utf-8",
"charsetSource": "utf8Detected",
"metadata": {
"version": 2, "errorCorrection": "M", "mask": 6,
"structuredAppend": { "index": 2, "total": 3, "parity": 89 }
}
},
{
"symbology": "qr", "frame": 0, "id": 1, "byteCount": 24,
"text": "One message, split acros", "textStatus": "valid", "charset": "utf-8",
"charsetSource": "utf8Detected",
"metadata": {
"version": 2, "errorCorrection": "M", "mask": 1,
"structuredAppend": { "index": 0, "total": 3, "parity": 89 }
}
},
{
"symbology": "qr", "frame": 0, "id": 2, "byteCount": 24,
"text": "s three QR codes and put", "textStatus": "valid", "charset": "utf-8",
"charsetSource": "utf8Detected",
"metadata": {
"version": 2, "errorCorrection": "M", "mask": 2,
"structuredAppend": { "index": 1, "total": 3, "parity": 89 }
}
}
],
"assemblies": [
{
"id": 0, "total": 3, "parity": 89, "complete": true, "componentIds": [ 1, 2, 0 ],
"association": "inferred", "byteCount": 71,
"text": "One message, split across three QR codes and put back together by read.",
"textStatus": "valid"
}
],
"errors": [], "warnings": []
}| Member of an assembly | Meaning |
|---|---|
totalparity | What the symbols of the set state. |
componentIds[] | The ids of the results that make up the message, in message order. |
complete | True when every index is present exactly once and the parity byte matches the assembled bytes. |
byteCounttext, textStatusbytesBase64 | The whole message, for a complete set. A character split between two symbols comes out intact. |
association | "inferred": the symbols were grouped by their total and parity, which is all a QR symbol says about its set. |
missingIndexes[]conflicts[] | For an incomplete set: the parts that were not found, and the indexes found more than once with different content. There is then no combined message. |
The parts always stay in results[]. "assembleStructuredAppend": false in reader leaves out assemblies[].
// After a successful read: the messages that were split across several symbols
int n = jsonOut.SizeOfArray("assemblies");
for (int i = 0; i < n; i++) {
jsonOut.I = i;
if (jsonOut.BoolOf("assemblies[i].complete")) {
Console.WriteLine(jsonOut.StringOf("assemblies[i].text"));
} else {
Console.WriteLine(jsonOut.SizeOfArray("assemblies[i].missingIndexes") + " of "
+ jsonOut.IntOf("assemblies[i].total") + " symbols are missing");
}
}// After a successful read: the messages that were split across several symbols
int n = jsonOut.SizeOfArray("assemblies");
for (int i = 0; i < n; i++) {
jsonOut.put_I(i);
if (jsonOut.BoolOf("assemblies[i].complete")) {
std::cout << jsonOut.stringOf("assemblies[i].text") << "\r\n";
} else {
std::cout << jsonOut.SizeOfArray("assemblies[i].missingIndexes") << " of "
<< jsonOut.IntOf("assemblies[i].total") << " symbols are missing\r\n";
}
}# After a successful read: the messages that were split across several symbols
n = jsonOut.SizeOfArray("assemblies")
for i in range(n):
jsonOut.I = i
if jsonOut.BoolOf("assemblies[i].complete"):
print(jsonOut.StringOf("assemblies[i].text"))
else:
print(jsonOut.SizeOfArray("assemblies[i].missingIndexes"), "of",
jsonOut.IntOf("assemblies[i].total"), "symbols are missing")detect
Locate symbols without decoding them
detect runs the search of read and stops before decoding. It reports where the QR symbols are and what speaks for each being one, and never their content. A symbol that cannot be decoded — damaged beyond the error correction, or too blurred — is still reported, which makes detect the way to tell "there is no code here" from "there is a code here that cannot be read".

{ "source": { "path": "damaged.png" } }{
"image": { "width": 360, "height": 185, "format": "png" },
"candidates": [
{
"symbology": "qr", "frame": 0, "id": 0, "decodeStatus": "notAttempted",
"geometry": {
"bounds": { "x": 30, "y": 30, "width": 125, "height": 125 },
"polygon": [
{ "x": 30, "y": 30 }, { "x": 155, "y": 30 }, { "x": 155, "y": 155 },
{ "x": 30, "y": 155 }
],
"rotation": 0, "moduleSize": 5, "mirrored": false, "inverted": false
},
"evidence": {
"finderPatterns": 3, "functionPatternMatch": 1, "timingPatternMatch": 1,
"alignmentPattern": true, "formatInformation": "valid", "formatBitErrors": 0,
"estimatedVersion": 2
}
},
{
"symbology": "qr", "frame": 0, "id": 1, "decodeStatus": "notAttempted",
"geometry": {
"bounds": { "x": 205, "y": 30, "width": 125, "height": 125 },
"polygon": [
{ "x": 205, "y": 30 }, { "x": 330, "y": 30 }, { "x": 330, "y": 155 },
{ "x": 205, "y": 155 }
],
"rotation": 0, "moduleSize": 5, "mirrored": false, "inverted": false
},
"evidence": {
"finderPatterns": 3, "functionPatternMatch": 0.93, "timingPatternMatch": 1,
"alignmentPattern": false, "formatInformation": "valid", "formatBitErrors": 0,
"estimatedVersion": 2
}
}
],
"errors": [], "warnings": []
}| Member | Meaning |
|---|---|
candidates[] | Always present, in position order; empty when nothing is found (which is success). There is no results[] and no assemblies[]. |
decodeStatus | Always "notAttempted". |
geometry | As for read: the same corner order, units and rounding. |
evidence.finderPatterns | The number of finder patterns the candidate was built from (3). |
evidence.functionPatternMatch | 0 to 1: the share of the function-pattern modules — finder patterns and separators, timing patterns, alignment patterns, the dark module, version information — that look as the estimated version draws them. A candidate is reported only at 0.85 or more. |
evidence.timingPatternMatch | The same for the timing patterns alone. |
evidence.alignmentPattern | Whether the alignment pattern near the fourth corner was found. Absent for version 1, which has none. |
evidence.formatInformationevidence.formatBitErrors | "valid" (read without correction), "corrected" (1 to 3 bits corrected; formatBitErrors says how many) or "unreadable". |
evidence.estimatedVersion | The QR version that the number of modules gives. |
A detect request takes source and limits as read does. From reader it takes symbologies, profile, region, tryRotate, tryInvert, tryMirror, tryDownscale and maxDetected (1–4096, default 100: reaching it is success with "stopReason": "maxDetected"). From results it takes includeGeometry and order. Everything that concerns decoding is optionNotApplicable — parse, reader.maxResults, expectedCount, allowDamaged, fallbackCharset, assembleStructuredAppend, and the other members of results — as is reader.maxDetected for read.
extract with includeUndecoded.What is read
The scope of the reader
What the reader of v11.8.0 handles, and where it stops.
Symbols
QR Code Model 2, versions 1–40, levels L/M/Q/H, all eight masks. Numeric, alphanumeric, byte, Kanji and Hanzi (GB/T 18284) data in any mix, ECI, FNC1 in first and second position, structured append.
Appearance
Any rotation, perspective (a symbol seen at an angle), mirror images, light on dark, several symbols per image, uneven lighting, moderate blur and noise. Modules of two pixels or more in a photograph; one pixel per module in a cleanly rendered image.
Damage
Reed-Solomon error correction to the limits of the standard, and format and version information with up to three wrong bits. diagnostics tells you how much was repaired.
Limits and errors
Stopping, limits and failures
The two limits of every operation apply to reading as well, and a read can end in three ways short of a full search.
| Member | Range | Default | For read, detect and extract |
|---|---|---|---|
limits.timeoutMs | 1–600,000 | 10,000 | A deadline for the whole call, including the decoding of the image file. |
limits.maxPixels | 1–67,108,864 | 16,777,216 | The largest width × height of the source image (each side is also limited to 32,768). Checked before the image is decoded. |
stopReason | Returns | Meaning |
|---|---|---|
"maxResults" | true | The search stopped at reader.maxResults or reader.expectedCount. results[] holds what was found. |
"maxDetected" | true | detect stopped at reader.maxDetected. |
"timeout""cancelled" | false | The deadline passed, or the application aborted the call. For read, results[] is still in the response, next to errors[], with the symbols decoded before the stop; for detect, candidates[] likewise. read and detect are the only operations whose failure response holds more than the error. |
Errors of reading
A failed call returns false with one entry in errors[], as every operation does. The request-rejection codes are those of the other operations; these are the ones specific to an image source. The messages shown are the real ones.
| Code | Path | Message | When |
|---|---|---|---|
inputFailed | /source/path | the source file does not exist, is empty or cannot be read | The file of source.path is missing, empty or unreadable. |
invalidImage | /source | the source is not a recognized image (PNG and JPEG are the supported encoded formats) | The data is not a well-formed PNG or JPEG: a wrong signature, a failed CRC, truncated or corrupt image data. |
unsupportedFeature | /source | — | A valid image that is outside what is decoded: interlaced or animated PNG, a JPEG outside the supported subset. |
resourceLimit | /source | the image has more pixels than limits.maxPixels allows | The image is larger than limits.maxPixels. |
missingOption | /source | a source image is required | The request has no source. |
unknownOption | /symbology | unknown option | A read request carries a member of the generate vocabulary (symbology, payload, render, …). |
optionNotApplicable | /reader/maxResults | this option applies to read; detect does not decode | An option of one read operation given to another. |