Perl でバーコードやQRコードの画像を出力したい場合、GDモジュールのサブセットにそれらの画像を生成するモジュールが提供されています。
インストール
sudo aptitude install libgd-barcode-perl
使用方法
バーコード
#!/usr/bin/env perl
use GD::Barcode::UPCE;
binmode(STDOUT);
print "Content-Type: image/png\n\n";
# バーコードを表示
print GD::Barcode->new('EAN13', '123456789012')->plot->png;
QRコード
#!/usr/bin/env perl
use GD::Barcode::QRcode;
binmode(STDOUT);
print "Content-Type: image/png\n\n";
# QR コードを表示
print GD::Barcode::QRcode->new('This is test',
{ Ecc=>'M', Version=>3, ModuleSize=>2 })->plot->png;
参照
GD::Barcode – GDでバーコード・イメージを作成します 【perldoc.jp】
※ 2020/07/02 度重なるブログ移転・ブログシステムのアップデートにより崩れた記事を校正。
