|
NAMEImage::PNG::QRCode - ABANDONED - Make PNG images containing QR codes from your text ABANDONEDThis module doesn't compile any more on my system. Fixing the problems will take more time than I have available, so it is abandoned, and bug reports against the module will be closed without any further response. SYNOPSIS use Image::PNG::QRCode 'qrpng';
qrpng (text => 'boom shake shake shake the room', out => 'shake.png');
(This example is included as synopsis.pl <https://fastapi.metacpan.org/source/BKB/Image-PNG-QRCode-0.11/examples/synopsis.pl> in the distribution.) VERSIONThis documents Image::PNG::QRCode version 0.11 corresponding to git commit 147e504525acbdce8d49e533578e99cdc2250b1d <https://github.com/benkasminbullock/image-png-qrcode/commit/147e504525acbdce8d49e533578e99cdc2250b1d> released on Fri May 16 09:32:07 2025 +0900. DESCRIPTIONThis module converts your 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 the PNG standard library "libpng" to be installed. "libpng" is usually already installed on Linux and Windows. FUNCTIONSqrpngmy $png = qrpng (text => 'this is my text'); This makes a scalar $png containing the QR code PNG data. qrpng (in => 'file.txt', out => 'file.png'); This makes a PNG file file.png from the contents of file.txt. qrpng options This function takes the following options.
DIAGNOSTICS
SCRIPTThere is a script "qrpng" installed with the module: qrpng "earphone pad" makes qrcode.png. Try qrpng --help for more options. EXAMPLESqrpng-data.plThis example makes a data URL QR code: use Image::PNG::QRCode 'qrpng';
use URI;
my $data = 'abcdefghijklmnopqrstuvwxyz';
my $u = URI->new ('data:');
$u->media_type ('image/png');
$u->data (qrpng (text => $data));
print "<img src='$u'>\n";
(This example is included as qrpng-data.pl <https://fastapi.metacpan.org/source/BKB/Image-PNG-QRCode-0.11/examples/qrpng-data.pl> in the distribution.) qrpng CGI scriptThis example CGI (common gateway interface) script makes a PNG from a user's input. use Image::PNG::QRCode 'qrpng';
use URI::Escape;
my $request = $ENV{QUERY_STRING};
if ($request) {
my %params;
my @params = split /\&/, $request;
for my $param (@params) {
my ($k, $v) = split /=/, $param;
if ($k && $v) {
$v =~ s/\+/ /g;
$params{$k} = uri_unescape ($v);
}
}
if ($params{w}) {
send_qr_code (%params);
}
}
print <<EOF;
Content-Type: text/plain
Status: 400
You didn't send anything, use me like this: qrpng.cgi?w=message-to-encode
EOF
exit;
sub send_qr_code
{
my (%params) = @_;
my $w = $params{w};
my $s;
eval {
qrpng (text => $w, out => \$s);
};
if ($@) {
print <<EOF;
Content-Type: text/plain
Status: 500
qrpng failed like this: $@
EOF
exit;
}
binmode STDOUT, ":raw";
my $l = length $s;
print <<EOF;
Content-Type: image/png
Content-Length: $l
$s
EOF
exit;
}
(This example is included as qrpng.pl <https://fastapi.metacpan.org/source/BKB/Image-PNG-QRCode-0.11/examples/qrpng.pl> in the distribution.) SEE ALSOAbout QR codesQRCode.com from Denso Wave <http://www.qrcode.com/en/index.html>, the inventors of the QR code, contains much information. Other QR code generatorsOn CPAN
Non-CPAN
BUGSThis section details some deficiencies of the module, and is probably only of interest to people who want to contribute to development. 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 everything for each image. 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 qrduino 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. The QR codes have only been checked by using two Android smartphones. COPYRIGHT AND LICENSEThe QR code creation part (the contents of qrencode.c in the distribution) is copyright 2010, Tom Zerucha, <https://github.com/tz1>. The rest of the module is copyright by Ben Bullock 2015-2018. This Perl module is licensed under the GNU General Public License version 3.
|