|
I have an Adaptec SlimSCSI 1460 PCMCIA adapter that hooks into my Thinkpad T41p. I've connected a HP ScanJet 6100c to that Adapter. Unfortunately, the SCSI cable delivered with the AHA 1460 is extremely short, so that I once run into intermittent SCSI bus resets only because the cable was not hooked exactly into the PCMCIA card (the difference was hardly visible).
Anyway, scanning works fine. I use the following Perl script that I call from any directory to scan multiple pages into one PDF. I can change the resolution and the color depth from page to page:
-
#!/usr/bin/perl
-
#
-
# This script scans a multipart image into a pdf
-
#
-
use strict;
-
-
my ($output) = join(" ", @ARGV);
-
-
#
-
# Define the scanner here.
-
#
-
my $scanner = "hp:/dev/sg0";
-
-
#
-
# Define the scan parameters here.
-
#
-
# Valid modes are:
-
# Lineart|Halftone|Grayscale|Color
-
#
-
my $xres = "210mm";
-
my $yres = "297mm";
-
my $left = "0mm";
-
my $top = "0mm";
-
my $mode = "Lineart";
-
my $res = "200dpi";
-
my $light = "0";
-
my $dir = "/tmp/scan";
-
my $file = "\@tmpscan";
-
my $time = `date + "%Y%m%d"`; chomp($time);
-
-
#
-
# Get the output file name and timestamp
-
#
-
if($output eq "") {
-
print "Enter the Filename (.pdf will be appended) [scan] : ";
-
chop (my $output = <STDIN>);
-
}
-
-
-
if($output !~ /^.*\s-\ s\d\d\d\d\d\d\d\d$/ && $output !~ /^.*\s-\ s\d\d\d\d\d\d\d\d\. [pP ][dD ][fF ]$/ ) {
-
print "Enter the Timestamp [$time] (n for none) : ";
-
chop (my $tmptime = <STDIN>);
-
-
if($tmptime ne "n") {
-
if($tmptime ne "") {
-
$output .= " - $tmptime";
-
} else {
-
$output .= " - $time";
-
}
-
}
-
}
-
-
if($output =~ /^(.*)\.[pP][dD][fF](.*)$/) {
-
$output = "$1$2.pdf";
-
} else {
-
$output .= ".pdf";
-
}
-
-
#
-
# Eventually create the working directory
-
#
-
if (!-d $dir) {
-
-
}
-
-
#
-
# Scan the pages
-
#
-
my $next = "";
-
my $page = 0;
-
getFormat($mode, $res);
-
do {
-
$page++;
-
system("scanimage -d $scanner --format pnm -x $xres -y $yres -l $left -t $top --mode $mode --brightness $light --resolution $res >\"$dir/$file$page.pnm\"");
-
$next = getFormat($mode, $res);
-
} while ($next ne "q");
-
-
#
-
# Convert to pdf
-
#
-
system("convert \"$dir/$file*\" -adjoin \"$output\"");
-
-
#
-
# Clean up the scanned pages
-
#
-
-
-
#
-
# Open the file
-
#
-
system("acroread \"$output\" &");
-
-
-
-
#
-
# Get the color depth
-
#
-
sub getFormat {
-
my ($curmode, $curres) = @_;
-
-
print "Enter the next page Format: LHGCXXX [". substr($curmode, 0, 1). substr($curres, 0, length($curres)- 3). "], q to finish : ";
-
-
chop (my $format = <STDIN>);
-
-
if($format =~ /^([lLhHgGcC])(.*)$/) {
-
-
$mode = "Lineart";
-
} elsif (uc($ 1) eq "H") {
-
$mode = "Halftone";
-
} elsif (uc($ 1) eq "G") {
-
$mode = "Grayscale";
-
} elsif (uc($ 1) eq "C") {
-
$mode = "Color";
-
}
-
if($2 ne "") {
-
$res = "$2dpi";
-
}
-
-
} elsif ($format =~ /^[qQ]$/) {
-
-
}
-
}
|