Scan a barcode with your CueCat and it creates a PNG of the barcode. It uses the Barcode::Cuecat and GD::Barcode modules. It's pretty simple really.
Updated: Removed a # and added a # (++
jeffa)
#!/usr/bin/perl
use strict;
use warnings;
use Barcode::Cuecat;
use GD::Barcode;
my $bc = new Barcode::Cuecat();
while (<>) {
$bc->scan($_);
my $type = $bc->type();
my $upc = $bc->code();
print "Type = ", $type, "\n";
print "Code = ", $upc, "\n";
print "S/N = ", $bc->serial(), "\n";
print " ------------\n";
# ITF goes unchanged
$type = "UPCA" if ($type eq 'UPA');
$type = "EAN8" if ($type eq 'E08');
$type = "EAN13" if ($type eq 'E13');
CreateBarCodes($type, $upc);
}
sub CreateBarCodes {
my ($type, $upc) = @_;
my $oGdBar;
my $sPtr;
if ($type eq "UPCA") {
$upc = "0".$upc if (length($upc) == 10); # if < 11 digi
+ts, add a 0 to the front
chop $upc if (length($upc) == 12); # if > 11 digits, remove
+ the check digit
}
$oGdBar = GD::Barcode->new($type, $upc);
die $GD::Barcode::errStr unless($oGdBar); #Invalid Length
open(IMG, ">./png/$upc.png") or die $!;
binmode(IMG);
print IMG $oGdBar->plot->png;
close(IMG);
#open(IMG, ">./png/sm_$upc.png") or die $!; # at work I have it pr
+oduce two different versions
#binmode(IMG);
#print IMG $oGdBar->plot(NoText=>1, Height => 20)->png;
#close(IMG); *** Thanks jeffa for pointing out my missing '#' ***
}