Imager::Barcode128 - Create GS1-128 compliant bar codes using Imager
use Imager::Barcode128; my $barcode = Imager::Barcode128->new( text => 'My cool barcode' ); $barcode->draw; $barcode->image->write(file => 'barcode.png');
If you want to generate GS1-128 compliant bar codes using Imager then look no further!
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
The Imager object to draw the bar code on to. Required.
The text to be encoded into the bar code. Required.
The x coordinate of the top left corner to start drawing the bar code. Defaults to 0.
The y coordinate of the top left corner to start drawing the bar code. Defaults to 0.
Get or set the x coordinate of the top left corner of where to start drawing the bar code.
Get or set the y coordinate of the top left corner of where to start drawing the bar code.
Get or set the color of the bar code. Defaults to
black. You can also pass an Imager::Color object.
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.
Get or set the height of the bar code. Defaults to the height of the
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.
Get or set the text to be encoded into the bar code.
Draws a barcode on the image. Returns
$self for method chaining.
This module will throw an Ouch if anything goes wrong. Under normal circumstances you should not expect to need to handle exceptions.
None that I can think of at this time.
- Bug Reports
Imager::Barcode128 is Copyright 2015 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.