Parse::WebCounter - Read the integer value of a web counter image
my $cp = new Parse::WebCounter();
my $imagetocheck = GD::Image->new("webcounterimage.gif");
my $value = $cp->readImage($imagetocheck);
print "Counter value is: $value\n";
This module parses web counter images using GD and supplies the numeric value represented by the image. Useful if you have a cron keeping track of the number of hits you are getting per day and you do not have real logs to go by. You will need copies of the images representing the individual digits, or a strip of all of them for it to compare to as the module is not very bright it does a simple image comparison as apposed to any sophisticated image analysis (This is not designed, nor intended to be a Captcha solver).
new Parse::WebCounter([<Class options>])
Creates and returns a new Parse::WebCounter object.
It can be created with the following class options that override the class defaults. They are listed here with their default options.
DIGITWIDTH => 15
The width of the individual digit items.
DIGITHEIGHT => 20
The height of the individual digit items.
STRIPORDER => '1234567890'
The order of the individual digits within a reference image strip.
MODE => 'STRIP'
There are two choices for this, STRIP and DIGITS. If strip is used then the module will attempt to load and break down a image strip of reference images (left to right, not top to bottom) named strip.gif. If the digits option is given then the module will instead look for individual digit images named 0.gif to 9.gif
TYPE => 'gif'
The image format to use. Most webcounters use gif format so that is the default value. Essentially it will be loading filename. TYPE
PATTERN => 'a'
The 'pattern' to use. The module will look under this directory name for the strip.gif or 0.gif-9.gif files. Allowing you to support multiple webcounters (through alternative class instances).
UNKNOWNCHAR => '_'
The character to return in place of an unmatched digit.
Reads the digits in the given image (or at least attempts to) and returns the "value" of the image as a string. If it fails to determine the value of any individual digit in the image the character _ will be returned or whatever character has be passed as UNKNOWNCHAR in the constructor.
This is intended as an internal function which is in fact called multiple times once with each "digit" of the full image to be parsed. It should be called with a single digit image and it will return the "value" of that image or the UNKNOWNCHAR if it fails to match it.
You will need to have GD compiled with support for the image format that your counters are displayed in. (Usually gif)
Add support to automaticaly retrieve reference images to the package
Thanks to Simon Proctor for prodding me with a sharp stick until I actually got on with something. :-)
Copyright (C) 2006 Peter Wise. All Rights Reserved
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
For the latest version check my website http://www.vagnerr.com/ or visit your favourite CPAN server.
Peter Wise (Vagnerr) - http://www.vagnerr.com/
To install Parse::WebCounter, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.