Email-Barcode-Decode

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Email-Barcode-Decode

0.04   21 September 2016
    - fixes to still work after debian/jessie
      libmagickwand-6.q16-2 libmagickcore-6.q16-2 imagemagick-common packages
      security update to 8:6.8.9.9-5+deb8u4

0.03   18 March 2016
    - improved B/W enhacing of image to be decoded

0.02    4 Feb 2016
    - scaling down images to 1500px, bigger images may not work well with Barcode::ZBar::Image
    - normalize and sharpen contrast before decoding

0.01    4 Jan 2013
        First version, released on an unsuspecting world.

README  view on Meta::CPAN

NAME
    Email::Barcode::Decode - decode barcodes out of an email

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"
            );
        }

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

lib/Email/Barcode/Decode.pm  view on Meta::CPAN

=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

t/01_Email-Barcode-Decode.t  view on Meta::CPAN

    my $ebd = Email::Barcode::Decode->new(email => $msg01);
    my @attached = @{$ebd->attached_files};
    is(scalar(@attached), 1, 'one attachment msg01.eml');

    my @symbols = $ebd->get_symbols;
    is(scalar(@symbols), 1, 'one barcode');
    is_deeply($symbols[0],{
        filename => 'barcode01.jpg',
        type     => 'QR-Code',
        data     => 'eusa:mpsexp:9',
    }, 'decoded data');
}

EMAIL_WITH_IMAGE2: {
    my $msg03 = file($Bin,'tdata','msg03.eml')->slurp;

    my $ebd = Email::Barcode::Decode->new(email => $msg03);
    my @attached = @{$ebd->attached_files};
    is(scalar(@attached), 1, 'one attachment msg03.eml');

    my @symbols = $ebd->get_symbols;
    is(scalar(@symbols), 1, 'one barcode');
    is_deeply($symbols[0],{
        filename => 'DPD-IMG_0013.jpg',
        type     => 'CODE-128',
        data     => 'eusa:mpsexp:939',
    }, 'decoded data');
}

if (which('gs')) {
    EMAIL_WITH_PDF: {
        my $msg02 = file($Bin,'tdata','msg02.eml')->slurp;

        my $ebd = Email::Barcode::Decode->new(email => $msg02);
        my @attached = @{$ebd->attached_files};
        is(scalar(@attached), 2, 'two pages');

t/01_Email-Barcode-Decode.t  view on Meta::CPAN

            type     => 'QR-Code',
            data     => 'BEGIN:VCARD
N:Jozef Kutej
ORG:meon
TITLE:IT Development
TEL:+4369918141077
URL:http://www.meon.eu/
EMAIL:jozef.kutej@meon.eu
ADR:Praterstrasse 15/3/22\\, 1020 Vienna\\, Austria
END:VCARD',
        }, 'decoded data 1');
        is_deeply($symbols[1],{
            filename => 'vcard-pdf-page2.jpg',
            type     => 'QR-Code',
            data     => 'http://search.cpan.org/perldoc?Email%3A%3ABarcode%3A%3ADecode',
        }, 'decoded data 2');
    }
} else {
    SKIP: {
        skip '- no `gs` found. Is Ghostscript installed?', 4;
    }
}



( run in 0.503 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )