Subject: | particle() will hang if largest image dimension is <= 19 |
Date: | Wed, 27 Feb 2008 15:05:06 +0000 |
To: | bug-GD-SecurityImage [...] rt.cpan.org |
From: | Matthew Franglen <Matthew.Franglen [...] semantico.com> |
Dear Sir,
GD::SecurityImage Version 1.64
I have discovered that the particle() method will hang if the largest
dimension of the image is less than 20. This will occur regardless of
any settings passed to particle. Looking at the code, the problem
section appears to be:
my $big = $self->{height} > $self->{width} ? $self->{height} :
$self->{width};
my $f = shift || $big * 20; # particle density
my $dots = shift || 1; # number of multiple dots
my $int = int $big / 20;
my @random;
for (my $x = $int; $x <= $big; $x += $int) {
push @random, $x;
}
With a maximum size of 19 or less, $big becomes 19 or less. This means
that $int becomes 0. This means that the loop never completes, as the
variable $x is incremented by 0 each round.
The following code will demonstrate the issue:
perl -MGD::SecurityImage -e 'GD::SecurityImage->new( width => 1, height
=> 1 )->random()->create()->particle();'
Regards,
--
Matthew Franglen
Software Developer
Semantico, Floor 1, 21-23 Dyke Road, Brighton BN1 3FE
t: +44 1273 358221
f: +44 1273 723232
e: Matthew.Franglen@semantico.com
w: www.semantico.com