NAME
Image::QRCode::Effects - Create snazzy QRCodes.
SYNOPSIS
use Image::QRCode::Effects;
my $image = Image::QRCode::Effects->new(
level => 'H',
plot => 'just another perl hacker',
);
$image->write(
outfile => 'qrcode.jpg',
colour => '#1500ff',
inner_shadow => 1,
round_corners => 1,
gradient => 1,
gradient_colour => '#ffa200',
gradient_type => 'radial',
);
DESCRIPTION
This module provides a collection of effects commonly used on QRCodes to make them look interesting.
It's designed for use with Imager::QRCode, although it'll likely work with any barcode images. Providing you don't stray too far from the default parameters, the resulting barcode should be easily readable.
CONSTRUCTOR
new(%args)
# Takes same arguments as Imager::QRCode, and additional 'plot' text
my $qrcode = Imager::QRCode->new(
plot => 'Fire walk with me',
size => 2,
margin => 2,
version => 1,
level => 'M',
casesensitive => 1,
lightcolor => Imager::Color->new( 255, 255, 255 ),
darkcolor => Imager::Color->new( 0, 0, 0 ),
);
# Or from file
my $qr = Image::QRCode::Effects->new( infile => '/path/to/barcode.jpg' );
# Or from Imager object (eg. Imager::QRCode, after calling ->plot)
my $qr = Image::QRCode::Effects->new( qrcode => $qrcode );
Returns an Image::QRCode::Effects
object, ready to call "write". For the parameters to Imager::QRCode, see that module's documentation.
METHODS
write(%args)
$qrcode->write(
outfile => '/my/new/barcode.jpg',
# dimensions
size => '600x600', # optional, default is '600x600'
# basic fill colour
colour => '#00ff00', # default #000000
# extra fill effects
gradient => 1, # optional, default 0
gradient_colour => '#ff0000',
gradient_type => 'normal', # normal|radial|plasma
# effects
# wave effect
wave => 1, # optional, default 0
wavelength => 30,
amplitude => 1.5,
# inner shadow effect
inner_shadow => 1, # optional, default 0
shadow_colour => '#cccccc', # default #000000
# rounded corners effect
round_corners => 1, # optional, default 0
corner_sigma => 2.2,
corner_threshold => '42%,58%',
);
Writes the barcode with effects to the specified outfile
.
There are three main effects: a wave-like effect, rounded corners and an inner shadow. In addition, there are several gradient fill options. These can be combined and each have parameters that can be altered to create unique images.
Parameters:
outfile
- File to write to. Required.size
- Dimensions of new image. Defaults to '600x600'.colour
- Primary fill colour of the barcodegradient
- Boolean, whether to fill the barcode with a gradient. Default is 0.gradient_colour
- Gradient colour to fill whengradient = 1
.gradient_type
- Type of gradient. Can benormal
(default),radial
orplasma
.wave
- Boolean, whether to warp the barcode with a wave effect. Default is 0.wavelength
- The length of the waves whenwave = 1
.amplitude
- The amplitude of the waves whenwave = 1
.inner_shadow
- Boolean, whether to apply an inner shadow. Default is 0.shadow_colour
- Colour of the shadow wheninner_shadow = 1
.round_corners
- Boolean, whether to round the corners of the barcode. Default is 0.corner_sigma
- Can be changed to adjust the 'roundedness' of the corners whenround_corners = 1
. Default is 2.2corner_threshold
- Can be changed to adjust the 'sharpness' of the corners whenround_corners = 1
. Default is '42%,58%'.
SEE ALSO
AUTHOR
Mike Cartmell, <mcartmell at cpan.org>
LICENSE AND COPYRIGHT
Copyright (C) 2013 Mike Cartmell
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/ for more information.