NAME

Image::PNG::QRCode - make a PNG image containing a QR code from text

SYNOPSIS

use Image::PNG::QRCode 'qrpng';
qrpng (text => 'boom shake shake shake the room', out => 'shake.png');

DESCRIPTION

This module converts input text to a PNG image of a QR code containing the text. The PNG image can either be stored to a file or it can be a scalar.

Image::PNG::Libpng requires "libpng" to be installed. "libpng" should already be installed on most Linux and Windows systems.

FUNCTIONS

qrpng

my $png = qrpng (text => 'this is my text');

This makes a scalar PNG data in $png containing the QR code PNG.

qrpng (in => 'file.txt', out => 'file.png');

This makes a PNG file file.png from the contents of file.txt.

qrpng options

text

Text to convert to a QR code.

in

in specifies an input file of text to convert to a QR code.

out

out specifies an output file or a scalar to put the PNG data into.

qrpng (out => 'file.png');

writes to file.png, but

qrpng (out => \$s);

writes the PNG data into a scalar $s.

version

Specify the "version" of the QR code. The "version" is like the size of the code. Maximum value is 40. If no version is specified, the program chooses one using the length of the text. If you choose a version which is too small for the input data, a fatal error occurs.

level

Specify the amount of error checking code (ECC) to use. The default is level one, which corresponds to 7% error tolerance. The level can go up to 4, which corresponds to 30% error tolerance. Values less than one or greater than four cause a fatal error.

quiet

Specify the size of the "quiet zone". The default is 4.

scale

Specify how many pixels one "module" (one block of the QR code) occupies. The default is 3. You can't use fractional values.

DIAGNOSTICS

%!$#"@*

This message is produced in the case of errors.

SCRIPT AND EXAMPLES

There is a script "qrpng" installed with the module:

qrpng "earphone pad" 

makes qrcode.png. Try

qrpng --help

for more options.

There is an example script qrpng.cgi in examples.

It makes a QR code for HTML:

SEE ALSO

About QR codes

QRCode.com from Denso Wave, the inventors of the QR code, contains much information.

Other QR code generators

On CPAN

Imager::QRCode

Imager::QRCode is based on the Imager module and libqrencode.

Text::QRCode

Text::QRCode makes a text QR code. It's based on libqrencode.

HTML::QRCode

HTML::QRCode is based on Text::QRCode.

Term::QRCode

Term::QRCode makes QR codes on terminal windows.

PostScript::Barcode::qrcode

This is part of PostScript::Barcode. It's actually PostScript rather than Perl.

Non-CPAN

qrduino

qrduino is a QR code generator developed for a platform called the Arduino. Image::PNG::QRCode is a fork of this project.

libqrencode

libqrencode is the library underlying Text::QRCode and its dependents.

Google Charts QR code generator

Google Charts offers a QR code generator. The QR codes generated by Image::PNG::QRCode are about 1/3 the size of the default Google charts ones, for example the "Hello world" example in the above documentation is 728 bytes, but Image::PNG::QRCode makes an equivalent QR code using only 243 bytes. The reason for the reduced size is that Google Charts uses RGB colour space, whereas Image::PNG::QRCode uses one-bit monochrome colour space.

ZXing

ZXing is a Java project which can generate QR codes. These are one-bit monochrome ones.

QrCode.net is a .Net version.

JavaScript qrcode generators

These might be a useful alternative to using a server-side solution:

http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/

http://code.google.com/p/jsqrencode/downloads/list

However, sending these JavaScript files over the internet results in much more bandwidth than sending the QR codes themselves.

BUGS

The QR code PNG files are very small and various tricks are used to make the memory use and the PNG file very small. Although the original plan was to interoperate with Image::PNG::Libpng, this ended up looking like a big burden to get only a small return, so this module actually just copies the parts of the code of Image::PNG::Libpng. If you want to manipulate the output PNG file you'll need to read it in again and operate on it.

The module isn't optimized for repeated uses, it builds up and tears down everyting.

The QR encoding is not checked for correctness. The QR code library comes from the "qrduino" project, but the contents have been worked on so it's not clear whether it's still correct. Also there was a bug in the original thing leading to reading uninitialized memory.

This encoder doesn't support the "shift-JIS" format. UTF-8 seems to pass through it OK. It doesn't use a BOM for the UTF-8.

COPYRIGHT AND LICENCE

The QR code creation part (the contents of qrencode.c in the distribution) is copyright 2010, tz@execpc.com. The rest of the module is copyright by Ben Bullock 2014.

This Perl module is licensed under the Gnu General Public Licence version 3.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 181:

Expected text after =item, not a bullet