Email-Barcode-Decode
view release on metacpan or search on metacpan
lib/Email/Barcode/Decode.pm view on Meta::CPAN
data => $_->get_data,
}}
grep { not($unique_data{$_->get_data}++) } # only new/unique
@new_symbols,
),
);
}
}
return @symbols;
}
sub _get_symbols_from_file {
my ($scanner, $file, $enhance_code) = @_;
my $magick = Image::Magick->new();
my $error = $magick->Read($file);
die $error if $error;
my ($raw, $raw_format) = $enhance_code->($magick);
my $image = Barcode::ZBar::Image->new();
$image->set_format($raw_format);
$image->set_size($magick->Get(qw(columns rows)));
$image->set_data($raw);
$scanner->scan_image($image);
return $image->get_symbols;
}
sub email_name {
my ($self) = @_;
my ($from) = Email::Address->parse($self->header_obj->header('From'));
return $from->name;
}
sub email_from {
my ($self) = @_;
my ($from) = Email::Address->parse($self->header_obj->header('From'));
return $from->address;
}
1;
__END__
=head1 NAME
Email::Barcode::Decode - decode barcodes out of an email
=head1 SYNOPSIS
my $ebd = Email::Barcode::Decode->new(email => $msg);
my @symbols = $ebd->get_symbols;
foreach my $symbol (@symbols) {
print(
'decoded ' . $symbol->{type} .
' symbol "' . $symbol->{data} .'"'.
' file "' . $symbol->{filename} .'"'.
"\n"
);
}
=head1 DESCRIPTION
This module can extract barcode information out of email attachments.
It processes all email image attachments. When Ghostscript is installed
it converts every page into image. Images are scanned for barcodes using
L<Barcode::ZBar>.
=head1 PROPERTIES
email
header_obj
attached_files
=head1 METHODS
=head2 new()
Object constructor. Requires C<email> string.
=head2 get_symbols()
Returns an array of hashed with barcode information. Ex.:
my @symbols = ({
filename => 'vcard-pdf-page2.jpg',
type => 'QR-Code',
data => 'http://search.cpan.org/perldoc?Email%3A%3ABarcode%3A%3ADecode',
});
=head1 AUTHOR
Jozef Kutej
=cut
( run in 2.004 seconds using v1.01-cache-2.11-cpan-5623c5533a1 )