JT Smith
and 1 contributors

NAME

Imager::Barcode128 - Create GS1-128 compliant bar codes using Imager

VERSION

version 0.0101

SYNOPSIS

 use Imager::Barcode128;

 my $barcode = Imager::Barcode128->new( text => 'My cool barcode' );
 $barcode->draw;
 $barcode->image->save(file => 'barcode.png');

DESCRIPTION

If you want to generate GS1-128 compliant bar codes using Imager then look no further!

EXPORTS

By default this module exports nothing. However, there are a number of constants that represent special characters used in the CODE 128 symbology that you may wish to include. For example if you are using the EAN-128 or UCC-128 code, the string to encode begins with the FNC1 character. To encode the EAN-128 string "00 0 0012345 555555555 8", you would do the following:

 my $barcode = Imager::Barcode128->new(text => FNC1.'00000123455555555558');

To have this module export one or more of these characters, specify them on the use statement or use the special token ':all' instead to include all of them. Examples:

 use Imager::Barcode128 qw(FNC1 Shift);
 use Imager::Barcode128 qw(:all);

Here is the complete list of the exportable characters. They are assigned to high-order ASCII characters purely arbitrarily for the purposes of this module; the values used do not reflect any part of the GS1-128 standard.

 FNC1   0xf7
 FNC2   0xf8
 FNC3   0xf9
 FNC4   0xfa
 Shift  0xfb

METHODS

new(text => 'Product #45')

Constructor.

image

The Imager object to draw the bar code on to. Required.

text

The text to be encoded into the bar code. Required.

x

The x coordinate of the top left corner to start drawing the bar code. Defaults to 0.

y

The y coordinate of the top left corner to start drawing the bar code. Defaults to 0.

x()

Get or set the x coordinate of the top left corner of where to start drawing the bar code.

y()

Get or set the y coordinate of the top left corner of where to start drawing the bar code.

color()

Get or set the color of the bar code. Defaults to black. You can also pass an Imager::Color object.

scale()

Get or set the scale of the bar code. Defaults to 2. Not recommended to set it to less than 2.

A bar in the bar code is 1 pixel wide per unit of scale.

height()

Get or set the height of the bar code. Defaults to the height of the image.

image()

Get or set the Imager object. Defaults to a 100px tall image with a white background. The image will be however long it needs to be to contain the bar code.

text()

Get or set the text to be encoded into the bar code.

draw()

Draws a barcode on the image. Returns $self for method chaining.

EXCEPTIONS

This module will throw an Ouch if anything goes wrong. Under normal circumstances you should not expect to need to handle exceptions.

TODO

None that I can think of at this time.

SEE ALSO

Most of the logic of this module was stolen from an older module called Barcode::Code128. I build this because I wanted to generate the bar codes with Imager rather than GD.

PREREQS

Moo Imager Ouch

SUPPORT

Repository

http://github.com/rizen/Imager-Barcode128

Bug Reports

http://github.com/rizen/Imager-Barcode128/issues

AUTHOR

JT Smith <jt_at_plainblack_dot_com>

LEGAL

Imager::Barcode128 is Copyright 2015 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.