::qr Experimental

The ::qr suffix returns a QR code, as an SVG image, for the page you are on or for any text you pass. It works on any URL of any host the platform serves.

Note: The QR suffix is experimental and may change.

Syntax

plain
https://name.rt.ht/docs/::qr
https://name.rt.ht/::qr?t=Hello
https://new.rt.ht/::qr?fg=%23e74c3c&bg=none&ec=H

The path ends in ::qr. It works on any URL of any host the platform serves, for example https://webpdf.pro/docs/::qr or https://rtcode.io/::qr.

Parameters

t

The text to encode. It overrides the URL. An empty value encodes the empty string.

s

The module size in pixels. The default is 6. 0, an empty value and values that are not numbers fall back to 6. Negative values clamp to 1.

m

The quiet-zone margin, in modules. The default is 2 when the parameter is absent. When it is present, the value is the integer, at least 0, so m= gives 0.

fg

The foreground color. The default is #000. Encode the # as %23.

bg

The background color. The default is #fff. none or transparent leaves out the background rectangle.

ec

The error-correction level: L, M, Q or H, in either case. The default is M. An invalid value becomes L.

What is encoded

Without t, the code encodes the request URL, with these changes:

To encode an edit URL such as https://host/?, pass it with t, URL-encoded.

Warning: On *.rt.ht hosts and most custom domains, the platform adds the dropped slash back when someone scans the code. Hosts that are exempt from that redirect, such as rtcode.io, answer 404 for the slashless URL. There, pass the full URL with t, for example ::qr?t=https%3A%2F%2Frtcode.io%2Fdocs%2F.

Response

CaseStatusContent-TypeBody
Success200image/svg+xmlThe QR code as SVG.
Data too long, or any other failure400text/plainQR Error: <message>, for example "QR Error: Data too long (1274 bytes) for EC level H".

Success responses carry Cache-Control: public, max-age=86400 and Access-Control-Allow-Origin: *.

The SVG has viewBox="0 0 W W", a width and height of W times s, and shape-rendering="crispEdges". An optional background <rect> is followed by a single <path> filled with fg. W is the module count plus twice the margin. The data is encoded in byte mode (UTF-8), and the QR version (1 to 40) and mask are chosen automatically.

Level (ec)Maximum data size, in UTF-8 bytes
L2,953
M2,331
Q1,663
H1,273

Access

Anyone can use it, on any URL, without signing in.

Examples

A QR code for the documentation

HTML

html
<img src="https://rtcode.io/::qr?t=https%3A%2F%2Frtcode.io%2Fdocs%2F&s=4" alt="QR code for rtcode.io/docs/">

Result

Any text, with high error correction

html
<img src="https://new.rt.ht/::qr?t=mailto:support@elefunc.com&ec=H&fg=%23e74c3c" alt="Email support">

This encodes the t text instead of the URL. The # in a color must be sent as %23. An invalid ec silently becomes L. The value is quoted because it contains =.

The current page

html
<img src="::qr?s=8&bg=none" alt="QR code for this page">

A relative ::qr encodes the current page, with 8-pixel modules and a transparent background. On https://name.rt.ht/docs/ it encodes https://name.rt.ht/docs, and the platform's 307 adds the slash back when the code is scanned.

Specifications

Not part of any specification. ::qr is an RTEdge.net feature. The code and the image follow:

Specification
ISO/IEC 18004: QR Code bar code symbology
Scalable Vector Graphics (SVG) 2

Availability

FeaturePlaygroundRTEdge.netNotes
::qr ExperimentalNoYesNot emulated in the playground.

See also