GD::Ba...:EAN13(3pm)

πŸ’– GD::Barcode::EAN13 β€” the vibe πŸ’–

okay bestie, so this little page is the manual for a Perl module that lives in the User Contributed Perl Documentation section, and it's called GD::Barcode::EAN13. You know, the one that makes EAN13 (aka JAN13) barcode pics with GD?? yeah. that one. let's get into it 😌✨


πŸŽ€ NAME πŸŽ€

GD::Barcode::EAN13 β€” bestie it literally makes EAN13(JAN13) barcode images and it does it with GD. that's the whole gig πŸ’…


🌸 SYNOPSIS 🌸

k so example numero uno, the CGI moment, ok:

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

and here's the same thing but with error check energy, because we love a safe queen 🫢

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

like... #Invalid Length is genuinely so real of it. it will simply die on you if the length is wrong. no cap. πŸ’€


πŸ¦‹ DESCRIPTION πŸ¦‹

so GD::Barcode::EAN13 is a subclass of GD::Barcode, right? and its whole purpose in life is letting you create EAN13(JAN13) barcode images with GD. iconic behavior honestly.

also PSA: this module is based on "Generate Barcode Ver 1.02 By Shisei Hanai 97/08/22". cute legacy vibes πŸ’œ

✨ new

$oGdBar = GD::Barcode::EAN13->new($sTxt);

the constructor!! it creates a GD::Barcode::EAN13 object for $sTxt. and here's the tea: $sTxt has to be 12 or 13 numeric characters ([0-9]). that's the rule, fr fr.

and if $sTxt has 12 characters, this module calculates CD for you. thoughtful. generous. we stan πŸ₯°

✨ 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 at new. $iHeight is, shocking twist, the height of the image. and if NoText is 1, the image has no text image of $sTxt. (yes it's a double "image", it said what it said 😭)

example time:

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

so like. you get a 20-pixel-tall image and it's text-free. minimalism. ate. πŸ’…

✨ barcode()

$sPtn = $oGdBar->barcode();

returns a barcode pattern as a string built out of '1', 'G' and '0'. the decoder ring is:

  • '1' means black
  • 'G' also means black, but a lil bit long πŸ‘€ (little bit long. ok periodt)
  • '0' means white

example:

my $oGdB = GD::Barcode::EAN13->new('123456789012');
my $sPtn = $oGdB->barcode();
# $sPtn = '';
lol yes the example literally shows $sPtn = ''; β€” that's what it says, bestie. i'm not out here editing the source material. πŸ™ˆ

✨ $errStr

$GD::Barcode::EAN13::errStr

this bad boy has the error message. when something goes wrong, this is where the drama lives. 😭

✨ $text

$oGdBar->{$text}

has the barcode text based on the $sTxt you specified in the new method. like it remembers what you gave it. loyal. πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Kawai Takanori β€” GCD00051@nifty.ne.jp


The GD::Barocde::EAN13 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.

(and yes, GD::Barocde is spelled exactly like that in the original. i said what i said. not my typo, not my problem πŸŽ€)


⭐ SEE ALSO ⭐

  • GD::Barcode

that's the whole page bestie, go forth and generate barcodes responsibly πŸ”₯

sign-off realness: this was perl v5.40.1, dated 2025-10-27, and it's the GD::Barcode::EAN13(3pm) page from the User Contributed Perl Documentation. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from