GD::Barcode(3pm)

πŸ’– NAME πŸ’–

GD::Barcode β€” ok so bestie, this is the module that creates barcode images using GD. That's it, that's the whole vibe. ✨

This is the manual page for GD::Barcode(3pm), and yes we're gonna read the whole thing together, no skimming, I got you. 🫢


🌈 SYNOPSIS 🌈

ex. CGI

use GD::Barcode::UPCE;
binmode(STDOUT);
print "Content-Type: image/png\n\n";
print GD::Barcode->new('EAN13', '123456789012')->plot->png;

with Error Check

my $oGdBar = GD::Barcode->new('EAN13', '12345678901');
die $GD::Barcode::errStr unless($oGdBar);     #Invalid Length
$oGdBar->plot->png;

See that little #Invalid Length comment? That's not me being dramatic, that's literally in the source. πŸ’€ Length goofs are real and they will find you.


πŸŽ€ DESCRIPTION πŸŽ€

GD::Barcode is a subclass of GD, and its whole main character job is letting you create barcode images with GD. Iconic behavior.

This module is based on "Generate Barcode Ver 1.02 By Shisei Hanai 97/08/22" β€” gotta respect the ancestors. πŸ‘‘

And here's the glow-up: from 1.14, you can use this module even if you don't have GD β€” with the one tiny exception of the plot method. So like, you can still vibe with the rest of it. πŸ’…

✨ new ✨

$oGdBar = GD::Barcode::UPCE->new($sType, $sTxt);

The constructor, bestie. It creates a GD::Barcode::$sType object for $sTxt. That's the whole thing β€” you pick your $sType, you hand over your $sTxt, and boom, object. πŸ¦‹

✨ plot() ✨

$oGd = $oGdBar->plot([Height => $iHeight, NoText => 0 | 1]);

This one creates a GD object with the barcode image for the $sTxt you specified back in the "new" method. $iHeight is the height of the image. And if NoText is 1, the image has no text image of $sTxt β€” so just bars, no little numbers underneath. Clean. Minimal. Aesthetic. πŸŽ€

ex.

my $oGdB = GD::Barcode->new('EAN13', '123456789012');
my $oGD = $oGdB->plot(NoText=>1, Height => 20);
# $sGD is a GD image with Height=>20 pixels, with no text.

✨ barcode() ✨

$sPtn = $oGdBar->barcode();

This returns a barcode pattern in string form, made of '1' and '0'. '1' means black, '0' means white. That's the whole legend, no cap. πŸ”₯

ex.

my $oGdB = GD::Barcode->new('UPCE', '123456789012');
my $sPtn = $oGdB->barcode();
# $sPtn = '';

^ and yes, that empty string at the end of the comment is exactly what the original says. Don't @ me, I just report the facts. 😭

✨ $errStr ✨

$GD::Barcode::errStr

has error message. That's it. That's the whole thing. Check it when things go sideways. πŸ™ˆ

✨ $text ✨

$oGdBar->{$text}

has barcode text based on the $sTxt you specified in the "new" method. So it remembers what you told it. Loyal. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Kawai Takanori GCD00051@nifty.ne.jp


The GD::Barcode module is Copyright (c) 2000 Kawai Takanori. Japan. All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. Pick your fighter, both are valid. ⭐


πŸ’œ SEE ALSO πŸ’œ

  • GD
  • GD::Barcode subclasses

And that's the whole page, bestie! Per the footer, this was written against perl v5.40.1 and dated 2025-10-27 β€” so yeah, this barcode module is out here aging like fine wine and still slaying. Go make some barcodes. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from