> > | QRCodePlugin
<--
Contributions to this plugin are appreciated. Please update the plugin page at
http://twiki.org/cgi-bin/view/Plugins/QRCodePlugin or provide feedback at
http://twiki.org/cgi-bin/view/Plugins/QRCodePluginDev.
If you are a TWiki contributor please update the plugin in the SVN repository.
-->
Create QR Code (a matrix barcode) in TWiki pages, useful for mobile applications
Introduction
This plugin generates QR Code in TWiki pages. A QR Code is a specific matrix barcode (or two-dimensional code), readable by dedicated QR barcode readers and camera phones. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be any text, such as phone numbers, URLs, gelocation, vCard, vCal and more.
Syntax Rules
%QRCODE{ "text" ... }%
Parameter |
Description |
Default |
"text" |
Text to encode as 2D barcode. |
(required) |
ecc="M" |
Error Correction Capability. Valid values "L" , "M" , "Q" , "H" . |
"M" |
version="..." |
Symbol version of QR Code, or size of matrix. Valid values "1" ... "40" , and "auto" for automatic versioning. See details below. |
"8" |
size="..." |
Module size, e.g. pixel size of a block (bit) that makes up the matrix of the barcode. |
"4" |
format="..." |
Format of HTML img tag of generated QR Code image. Supported variables: $urlpath - URL path of image, $width - image width, $height - image height. |
"<img src='$urlpath' width='$width' height='$height' border='0' alt='' />" |
QR Code has error correction capability (ECC) to restore data if the code is dirty or damaged:
- level
"L" - about 7%
- level
"M" - about 15%
- level
"Q" - about 25%
- level
"H" - about 30%
The length of text (number of bytes) and the ECC determine the symbol version (e.g. matrix size) required to encode some text. A version="auto" selects the version automatically based on text length and ECC. See "Attention" note in the "Plugin Installation & Configuration" section below before using "auto" .
Overview of symbol version for default ECC level "M" :
Version |
Matrix size |
Max. bytes |
1 |
21x21 |
14 |
2 |
25x25 |
26 |
3 |
29x29 |
42 |
4 |
33x33 |
62 |
5 |
37x37 |
84 |
6 |
41x41 |
106 |
7 |
45x45 |
122 |
8 |
49x49 |
152 |
9 |
53x53 |
180 |
10 |
57x57 |
213 |
|
Version |
Matrix size |
Max. bytes |
11 |
61x61 |
251 |
12 |
65x65 |
287 |
13 |
69x69 |
331 |
14 |
73x73 |
362 |
15 |
77x77 |
412 |
16 |
81x81 |
450 |
17 |
85x85 |
504 |
18 |
89x89 |
560 |
19 |
93x93 |
624 |
20 |
97x97 |
666 |
|
Version |
Matrix size |
Max. bytes |
21 |
101x101 |
711 |
22 |
105x105 |
779 |
23 |
109x109 |
857 |
24 |
113x113 |
911 |
25 |
117x117 |
997 |
26 |
121x121 |
1059 |
27 |
125x125 |
1125 |
28 |
129x129 |
1190 |
29 |
133x133 |
1264 |
30 |
137x137 |
1370 |
|
Version |
Matrix size |
Max. bytes |
31 |
141x141 |
1452 |
32 |
145x145 |
1538 |
33 |
149x149 |
1628 |
34 |
153x153 |
1722 |
35 |
157x157 |
1809 |
36 |
161x161 |
1911 |
37 |
165x165 |
1989 |
38 |
169x169 |
2099 |
39 |
173x173 |
2213 |
40 |
177x177 |
2331 |
|
The size of the generated image depends on the symbol version and the module size. For example, version="2" and size="3" results in a 99x99 pixels image. Version 2 has matrix size 25x25. A module size 3 turns that into 3 times 25x25 pixels, or 75x75 pixels. There is some required whitespace, which results in a 99x99 pixels image size.
See also VarQRCODE documentation for TWikiVariables.
Examples
Small QR Code for URL http://twiki.org/
You type |
You get (if installed) |
Simulated example |
%QRCODE{
"http://twiki.org/"
version="2"
size="3"
}%
|
QRCode Plugin Error: Can't locate object method "new" via package "GD::Image" (perhaps you forgot to load "GD::Image"?) at /usr/local/share/perl5/GD/Barcode/QRcode.pm line 304.
|
|
Encode URL of current topic
The QR Code of the current topic can be placed in a TWiki skin so that the URL can easily be read by smart phones. We use symbol version 8, e.g. the URL cannot be longer than 152 characters.
You type |
You get (if installed) |
Simulated example |
%QRCODE{
"%SCRIPTURL{view}%/%WEB%/%TOPIC%"
version="8"
size="4"
}%
|
QRCode Plugin Error: Can't locate object method "new" via package "GD::Image" (perhaps you forgot to load "GD::Image"?) at /usr/local/share/perl5/GD/Barcode/QRcode.pm line 304.
|
|
Pulldown menu with QR Code
You can add a QR Code pulldown to the TopMenuSkin so that smartphone users can easily bookmark any TWiki page. Add the following to your TopMenuSkinTopicMenu after the Edit pulldown bullets:
You type |
You get (if installed) |
Simulated example |
* [[%BASEWEB%.%BASETOPIC%][<img
src="%PUBURLPATH%/%SYSTEMWEB%/QRCodePlugin/
qrcode.gif" alt="" width="16" height="16"
/> %ICON{menu-down}%]]
* [[%SYSTEMWEB%.QRCodePlugin][%QRCODE{
"%SCRIPTURL{view}%/%BASEWEB%/%BASETOPIC%"
version="auto" size="4" }%]]
|
<---->
<-- -->
|
|
Interactive example
You can encode any text with this interactive form. The matrix size is set automatically using version="auto" .
You type |
You get (if installed) |
Simulated example |
<form action="%SCRIPTURL{view}%/%WEB%/%TOPIC%#QrForm">
<input type="text" name="qrcode" value="%URLPARAM{ "qrcode" encode="entity" default="Enter text" }%" size="20" class="twikiInputField" /><br />s
<input type="submit" value="Generate QR Code" class="twikiSubmit" />
</form>
%QRCODE{
"%URLPARAM{ "qrcode" encode="quote" default="Enter text" }%"
version="auto"
}%
|
QRCode Plugin Error: Can't locate object method "new" via package "GD::Image" (perhaps you forgot to load "GD::Image"?) at /usr/local/share/perl5/GD/Barcode/QRcode.pm line 304.
|
|
Plugin Installation & Configuration
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
- For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.
- Or, follow these manual installation steps:
- Download the ZIP file from the Plugins home (see below).
- Unzip
QRCodePlugin.zip in your twiki installation directory. Content: File: | Description: | data/TWiki/QRCodePlugin.txt | Plugin topic | data/TWiki/VarQRCODE.txt | QRCODE variable documentation topic | lib/TWiki/Plugins/QRCodePlugin.pm | Plugin Perl module | lib/TWiki/Plugins/QRCodePlugin/Core.pm | Plugin core module | pub/TWiki/QRCodePlugin/twiki-logo-80x40-t.gif | Logo file | pub/TWiki/QRCodePlugin/qrcode-example-*.png | Example QR Code image files |
- Set the ownership of the extracted directories and files to the webserver user.
- Install the dependencies.
- Plugin configuration and testing:
- Run the configure script and enable the plugin in the Plugins section.
- Test if the installation was successful: See example above.
Attention, CPAN:GD::Barcode::QRcode version 1.15 needs to be patched as follows before you can use version="auto" :
--- /usr/lib/perl5/site_perl/5.8.0/GD/Barcode/QRcode.pm.save1 2004-04-23 23:35:34.000000000 -0700
+++ /usr/lib/perl5/site_perl/5.8.0/GD/Barcode/QRcode.pm 2011-02-11 22:37:13.000000000 -0800
@@ -37,7 +37,7 @@
$oSelf->{text} = $sTxt;
$oSelf->{Ecc} = $rhPrm->{Ecc} || ' ';
$oSelf->{Ecc} =~ tr/LMHQ/M/c; #Not /LMQH/ => M
- $oSelf->{Version} = $rhPrm->{Version} || 1;
+ $oSelf->{Version} = $rhPrm->{Version} || 0;
$oSelf->{ModuleSize} = $rhPrm->{ModuleSize} || 1;
$oSelf->{ModuleSize} = int($oSelf->{ModuleSize});
Plugin Info
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Create QR Code (a matrix barcode) in TWiki pages, useful for mobile applications
Related Topics: VarQRCODE, TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences
META FILEATTACHMENT |
attachment="qrcode-example-1.png" attr="h" comment="" date="1297312514" name="qrcode-example-1.png" path="qrcode-example-1.png" size="305" user="TWikiContributor" version="1" |
META FILEATTACHMENT |
attachment="qrcode-example-2.png" attr="h" comment="" date="1297321158" name="qrcode-example-2.png" path="qrcode-example-2.png" size="676" user="TWikiContributor" version="1" |
META FILEATTACHMENT |
attachment="qrcode-example-3.png" attr="h" comment="" date="1297546847" name="qrcode-example-3.png" path="qrcode-example-3.png" size="230" user="TWikiContributor" version="1" |
META FILEATTACHMENT |
attachment="qrcode-example-4.png" attr="h" comment="" date="1297727291" name="qrcode-example-4.png" path="qrcode-example-4.png" size="6006" user="PeterThoeny" version="2" |
META FILEATTACHMENT |
attachment="qrcode.gif" attr="h" comment="" date="1297723592" name="qrcode.gif" path="qrcode.gif" size="138" user="TWikiContributor" version="1" |
|