diff --git a/index.php b/index.php index f2abf6d..fc7fa78 100644 --- a/index.php +++ b/index.php @@ -9,79 +9,71 @@ array("pipe", "r"), // stdin is a pipe that the child will read from - 1 => array("pipe", "w"), // stdout is a pipe that the child will write to - 2 => array("pipe", "w") // stderr is a file to write to - ); - $env=array(); - $process = proc_open("/usr/bin/sane-find-scanner", $findScanner, $pipes, '/tmp', $env); - if (is_resource($process)) { - $data = stream_get_contents($pipes[2]); - $data .= stream_get_contents($pipes[1]); - } - proc_close($process); - $match = preg_match('/libusb:\d+:\d+/', $data, $matches); - if ($match&&count($matches)) { - $address=$matches[0]; - } - $descriptorspec = array( - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from - 1 => array("pipe", "w"), // stdout is a pipe that the child will write to - 2 => array("pipe", "w") // stderr is a file to write to - ); - $cwd = '/tmp'; - $env = array(); - - $process = proc_open("/usr/bin/scanimage -d $device --output-file ". - "$scans_dir . $fileName-%04d --quick-format Letter". - " --mode $_POST[mode] --resolution $_POST[quality] --source Automatic Document Feeder", $descriptorspec, $pipes, $cwd, $env); - - if (is_resource($process)) { - $errors = stream_get_contents($pipes[2]); - $output = stream_get_contents($pipes[1]); - } - - $dirList = scandir($scans_dir); - $inputFiles = array(); - $firstFile = ""; - foreach ($dirList as $file) { - if (stristr($file, $fileName)) { - //this is one of our input files - if ($firstFile=="") $firstFile = $file; - array_push($inputFiles, $file); - } - } - - if (count($inputFiles)) - { - $path=""; - foreach ($inputFiles as $file) { - $path .= "pnm:" . $scans_dir . $file; - } - $output = `/usr/bin/convert pnm:$scans_dir$firstFile -resize '>300x' -strip $scans_dir$firstFile.jpg`; - $output .= `/usr/bin/convert -page a4 $path $scans_dir$fileName.pdf`; - echo "Scan Successful!"; - } else { - echo "Scan Failed! No pages were scanned. Is there a document in the scanner?"; + $descriptorspec = array( + 0 => array("pipe", "r"), // stdin is a pipe that the child will read from + 1 => array("pipe", "w"), // stdout is a pipe that the child will write to + 2 => array("pipe", "w") // stderr is a file to write to + ); + $cwd = '/tmp'; + $env = array(); + $process = proc_open("$scanimage -d $_POST[device] --output-file $scans_dir$fileName-%04d --source $_POST[source] --mode ". + "$_POST[mode] --resolution $_POST[resolution] -l $_POST[l] -t $_POST[t] -x $_POST[x] -y $_POST[y]", $descriptorspec, $pipes, $cwd, $env); + if (is_resource($process)) { + $errors = stream_get_contents($pipes[2]); + $output = stream_get_contents($pipes[1]); } + $dirList = scandir($scans_dir); + $inputFiles = array(); + $firstFile = ""; + foreach ($dirList as $file) { + if (stristr($file, $fileName)) { + if ($firstFile=="") $firstFile = $file; + array_push($inputFiles, $file); + } + } + if (count($inputFiles)) { + $path=""; + foreach ($inputFiles as $file) { + $path .= "pnm:" . $scans_dir . $file; + } + $output = `/usr/bin/convert pnm:$scans_dir$firstFile -resize '>300x' -strip $scans_dir$firstFile.jpg`; + $output .= `/usr/bin/convert -page a4 $path $scans_dir$fileName.pdf`; + echo "Scan Successful!"; + } else { + echo "Scan Failed! No pages were scanned. Is there a document in the scanner?"; + } ob_flush(); echo ""; -} + } ?>
@@ -128,10 +120,9 @@ if (isset($_POST["scan"])) {
- +
-

File Options

@@ -144,10 +135,9 @@ if (isset($_POST["scan"])) {
-
+
-

Page Size