1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-12 11:10:27 +00:00
TiddlyWiki5/plugins/tiddlywiki/qrcode/docs/makeqr.tid

49 lines
1.5 KiB
Plaintext
Raw Normal View History

title: $:/plugins/tiddlywiki/qrcode/docs/qrcode
tags: $:/tags/QRCodeDocs
caption: makeqr Macro
The ''makeqr'' [[macro|Macros]] converts text data into an image of the corresponding QR code. The image is returned as [[base64-encoded data URI|https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs]].
!! Parameters
;text
: The text to encode
;size
: The size of the image in pixels (defaults to 500)
;errorCorrectLevel
2024-10-09 11:11:44 +00:00
: Determines the amount of error correction applied to the image (see below, defaults to "M")
;fallback
: The fallback image to be returned in case of an error (see below)
The conversion will fail if the text is too long and/or complex and the macro will return the provided fallback image. If no fallback image is provided then an error image is generated.
The error correction level is a [[QR code feature|http://www.qrcode.com/en/about/error_correction.html]]:
2024-10-09 11:11:44 +00:00
|errorCorrectLevel |Redundancy |Use cases |h
|L | 7%|Clean environment, large amount of data |
|M | 15%|Default value, most common choice |
|Q | 25%|Dirty environment, small amount of data |
|H | 30%|~|
2016-10-20 08:45:04 +00:00
!! Examples
2024-10-09 11:11:44 +00:00
Making a QR code data URI for a simple string of text:
2016-10-20 08:45:04 +00:00
```
<<makeqr "Hello there!">>
```
2024-10-09 11:11:44 +00:00
Displaying a QR code for a simple string of text:
2016-10-20 08:45:04 +00:00
```
2024-10-09 11:11:44 +00:00
<img src=<<makeqr "Hello there!">> />
2016-10-20 08:45:04 +00:00
```
2024-10-09 11:11:44 +00:00
Displaying a QR code for a transcluded value (URL of the current wiki):
2016-10-20 08:45:04 +00:00
```
2024-10-09 11:11:44 +00:00
\define qr(content) <img src=<<makeqr text:"""$content$""">> />
<$transclude $variable="qr" content={{$:/info/url/full}} />
2016-10-20 08:45:04 +00:00
```