App-QRCodeUtils
view release on metacpan or search on metacpan
lib/App/QRCodeUtils.pm view on Meta::CPAN
my %args = @_;
my $str = Image::DecodeQR::decode($args{filename});
[200, "OK", $str];
}
$SPEC{gen_qrcode} = {
v => 1.1,
summary => 'Generate QR Code and by default show it (or save it to a file)',
args => {
text => {
schema => 'str*',
req => 1,
pos => 0,
},
filename => {
schema => 'filename*',
pos => 1,
description => <<'MARKDOWN',
If unspecified, will save to a temporary filename and show it with
<pm:Desktop::Open>.
MARKDOWN
},
format => {
schema => ['str*', in=>[qw/png html txt/]],
default => 'png',
},
level => {
summary => 'Error correction level',
schema => ['str*', in=>['L', 'M', 'Q', 'H']],
default => 'M',
},
},
examples => [
],
};
sub gen_qrcode {
require QRCode::Any;
my %args = @_;
my $format = $args{format} // 'png';
my $filename = $args{filename};
unless (defined $filename) {
require File::Temp;
(undef, $filename) = File::Temp::tempfile("qrcodeXXXXXXXXX", TMPDIR=>1, SUFFIX=>".$format");
}
my $res = QRCode::Any::encode_qrcode(
format => $format,
text => $args{text},
filename => $filename,
level => $args{level},
);
return $res unless $res->[0] == 200;
require Desktop::Open;
Desktop::Open::open_desktop($filename);
[200, "OK", undef, {"func.filename"=>$filename}];
}
1;
# ABSTRACT: Utilities related to QR Code
__END__
=pod
=encoding UTF-8
=head1 NAME
App::QRCodeUtils - Utilities related to QR Code
=head1 VERSION
This document describes version 0.005 of App::QRCodeUtils (from Perl distribution App-QRCodeUtils), released on 2026-01-20.
=head1 DESCRIPTION
This distributions provides the following command-line utilities:
=over
=item * L<decode-qrcode>
=item * L<gen-qrcode>
=back
=head1 FUNCTIONS
=head2 decode_qrcode
Usage:
decode_qrcode(%args) -> [$status_code, $reason, $payload, \%result_meta]
Decode QR Code.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<filename>* => I<filename>
(No description)
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
( run in 0.772 second using v1.01-cache-2.11-cpan-df04353d9ac )