NAME
Scanner::Device - Class to control scanner hardware via SANE scanimage CLI.
SYNOPSIS
use Scanner::Device;
$obj = Scanner::Device->new ( hashargs );
$bool = Scanner::Device->defaultScannerIs ($scanner);
$bool = Scanner::Device->defaultDpiIs ($dpi);
$true = Scanner::Device->defaultShutdownIs ($bool);
$bool = Scanner::Device->defaultPageSourceIs ($pgsrc);
$bool = $obj->scan ($pgobj,$dpath);
$bool = $obj->shutdown;
Inheritance
UNIVERSAL
Description
Creates Scanner::Device objects that represent a scanner to which Scanner::Page objects may be passed for scanning.
Examples
use Scanner::Device;
use Scanner::Device::Page;
my $bool = Scanner::Device->defaultScannerIs ("hp:libusb:001:010");
$bool = Scanner::Device->defaultDpi (150);
$bool = Scanner::Device->defaultPageSourceIs ("adf");
my $scanner = Scanner::Device->new;
my $pg = Scanner::Page->new ( 'date' => "20040830",
'title' => "DailyBoggle",
'pageid' => "001",
);
my $bool = $scanner->scan ( $pg );
Class Variables
$Scanner::DEFAULT_SCANNER Default is "umax". If there is an $SCANNER
Environment variable, that value will be used
instead.
$Scanner::DEFAULT_DPI Default is 150 dpi. If the Scanner is an
hp5590, it will be set to 200 dpi instead.
$Scanner::DEFAULT_PAGESOURCE Default source is "flatbed".
$Scanner::DEFAULT_SHUTDOWN Default is false, for no shutdown.
Instance Variables
scanner Default device is "umax" or the contents of the Environment
variable $SCANNER. It can also be a usb device like
"hp:libusb:001:01"
type The device type portion of the scanner string.
deviceid The device address portion of the scanner string.
pagesource Default page source is "flatbed". It can be either 'flatbed'
or 'adf' for automatic document feeder. This value will be used
to select the best available and possibly device specific internal
setting for 'devpgsrc', as allowed by scanimage.
devpgsrc Best match to requested 'pagesource' that is available on the
scanner 'type'.
extra Type dependant args. These are set automatically based on 'type'.
dpi Default value of dots per inch is 150. scanimage measure pages in
mm and uses dpi to measure resolution. Don't ask me, ask them.
Environment Variables
$SCANNER If defined and if it contains a valid scanner device string at
load time, it will be used as the default scanner.
$SCANNER_AUTO_SHUTDOWN
If defined at load time, it will be used as the default boolean
value for $Scanner::DEFAULT_SHUTDOWN.
Class Methods
Note that argument validity checking is not implimented yet.
- $bool = Scanner::Device->defaultScannerIs ($device)
-
Set the default device for the Scanner::Device class. The device string may be anything allowed by the scanimage program. You can find out what is available using the command:
scanimage -L
If the device argument is missing, the value defaults to "umax" for no better reason than that is was the scanner I had when I first wrote this code.
If the device is an hp5590, the default dpi setting is raised from 150 dpi to 200 dpi since that scanner does not have a 150 dpi setting.
Returns true on success and false if there is no arg or it is not a scanner device string.
- $bool = Scanner::Device->defaultDpiIs ($dpi)
-
Set the default dots per inch for the Scanner::Device Class. The dpi integer may be anything allowed by the scanner.
Returns true on success and false if there is no arg or it is not a valid dpi value.
- $bool = Scanner::Device->defaultPageSourceIs ($pgsrc)
-
Set the Class default scanner page source. Flatbed/Normal or ADF (automatic document feeder). "flatbed" or "normal" means the scanner table; "adf" means use an automatic document feeder.
Note that at object-creation time the appropriate device tupe dependant pseudonym of flatbed or normal will be used regardless of which was named the default.
The page source string will in some cases be internally mapped to scanner specific equivalents, for example flatbed=>normal for some HP scanners. Either flatbed or normal is acceptable on input. The appropriate one will be used when actually communicating with the scanner.
Returns true on success and false if there is no arg or it is not a valid page source.
- $bool = Scanner::Device->defaultShutdownIs ($boolean)
-
Set the default for shutdown after a scan. 1 means carry out special shutdown such as turning off the lamp, if required; 0 or undef means do not do so. It is often useful not to do a shutdown if you are scanning multiple pages as it can slow down your scanning immensely.
The $boolean arg should be 1 or 0 to make things easier to understand, but it can be absolutely anything. whatever it is will be interpreted as true or false, ie "anystring" is true; "" is false, undef is false, etc.
Always returns true.
- $obj = Scanner::Device->new (scanner => $devicestr, pagesource => $src, dpi => $dpi
-
This is the Class method for creating new Scanner::Device objects and has three option args:
scanner => scanner type as returned by "scanimage -L" [OPT: default is "umax"] pagesource => flatbed|adf. Any other value will be changed to flatbed. [OPT: default is "flatbed"] dpi => integer [OPT: default is 150 dpi]
It returns either a pointer to the newly created and initialized object or undef if the object could not be created.
Instance Methods
- $bool = $obj->scan ($pageobj,$dpath)
-
Scan the page identified by the pageobj and create an appropriately named file at $dpath. The $dpath location must be a directory that is writeable to the user.
Returns true if it succeeds.
If debug is enabled, it will print the generated scanimage command line before executing it.
- $bool = $obj->shutdown
-
Turn the scanner off if it is a type which requires special handling that we know about. Only used for Mustek at the moment, noop otherwise.
Private Class Methods
None.
Private Instance Methods
None.
Errors and Warnings
None.
KNOWN BUGS
See TODO.
SEE ALSO
Scanner::Page, Scanner::Format.
AUTHOR
Dale Amon <amon@vnl.com>
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 449:
=back doesn't take any parameters, but you said =back 4
- Around line 471:
=back doesn't take any parameters, but you said =back 4