Posted on 2007-01-31 02:03:36-08 by mccomber
new GD::Image fails in Captcha.pm

Hi,

I'm trying to implement this module on a SuSE box with Perl 5.8.7. I was getting an error so I added some debugging print/die lines as such:

my $letter = substr($code,$i,1); my $letter_png = File::Spec->catfile($self->images_folder(),$letter . ".png"); print "\n" . $letter_png . "\n"; my $source = new GD::Image($letter_png) || die "DIE error: $!"; $im->copy($source,($i*($self->width()),0,0,0,$self->width(),$self->height()));

The result is:

/home/www/webmail.mccomber.ca/captcha/7.png DIE error: No such file or directory at /usr/lib/perl5/site_perl/5.8.7/Authen/Captcha.pm line 396.

So it appears to me that File::Spec is working but that GD::Image is failing for some reason. Without my debugging code the error is:

Use of uninitialized value in subroutine entry at /usr/lib/perl5/site_perl/5.8.7/Authen/Captcha.pm +line 397. source is not of type GD::Image at /usr/lib/perl5/site_perl/5.8.7/Authen/Captcha.pm line 397.

My implementation of Authen::Captcah is as follows:

#!/usr/bin/perl -w use strict; use Authen::Captcha; my $captcha = Authen::Captcha->new( data_folder => '/home/www/webmail.mccomber.ca/captcha', output_folder => '/home/www/webmail.mccomber.ca/html/captcha', expire => 300, width => 25, height => 35, images_folder => '/home/www/webmail.mccomber.ca/captcha', keep_failures => 0, debug => 2 ); ### DEBUG CONSTANT ### my $number_of_characters = 4; # create a captcha. Image filename is "$md5sum.png" my $md5sum = $captcha->generate_code($number_of_characters);

There's more but the script fails at the above line. All the folders defined have RWX for UG and RX for O. I can't figure out what is wrong.

Regards,
Doug

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.