interaction on sommer
[sgn.git] / lib / CXGN / QRcode.pm
blobf9777db15ac7daa1bc9771967752a7dfb8e90689
1 package CXGN::QRcode;
3 use Moose;
4 use GD;
6 use Imager::QRCode;
8 has 'text' => (
9 isa => 'Str',
10 is => 'rw',
11 required => 1,
14 has 'size' => (
15 isa => 'Maybe[Int]',
16 is => 'rw',
17 default => 3,
20 has 'margin' => (
21 isa => 'Maybe[Int]',
22 is => 'rw',
23 default => 5,
26 has 'version' => (
27 isa => 'Maybe[Int]',
28 is => 'rw',
29 default => 1,
32 has 'level' => (
33 isa => 'Maybe[Str]',
34 is => 'rw',
35 default => 'M',
38 sub get_barcode_file {
39 my $self = shift;
40 my $file = shift;
42 my $qrcode = Imager::QRCode->new(
43 size => $self->size,
44 margin => $self->margin,
45 version => $self->version,
46 level => $self->level,
47 casesensitive => 1,
48 lightcolor => Imager::Color->new(255, 255, 255),
49 darkcolor => Imager::Color->new(0, 0, 0),
51 my $barcode = $qrcode->plot( $self->text );
52 $barcode->write(file => $file);
54 return $file;