From b678c03f558ea9dd88fb70ad7b3dbfebda88ecad Mon Sep 17 00:00:00 2001 From: Josh North Date: Thu, 28 Aug 2014 21:40:30 -0400 Subject: [PATCH] stopping at a working point for now. pdf only but crops correctly at least --- index.php | 97 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/index.php b/index.php index 63dfc72..ba6970e 100644 --- a/index.php +++ b/index.php @@ -24,21 +24,21 @@

Device Setup

-
- - +
- @@ -46,12 +46,14 @@
-
+ +
@@ -59,33 +61,33 @@

File Options

-
- +

Page Size (in mm)

- +
- +
- +
- +
@@ -95,17 +97,19 @@ // initialize scanned files directory path $scans_dir = $app_dir . $scan_dir; // set post variables - if(isset($_POST['sResolution'])) { $pResolution = $_POST['sResolution']; }; - if(isset($_POST['sX'])) { $pX = $_POST['sX']; }; + if(isset($_POST['sResolution'])){$pResolution = $_POST['sResolution'];}; + if(isset($_POST['sX'])){$pX = $_POST['sX'];}; // decide to use scanimage if Flatbed or scanadf if ADF if (isset($_POST['source'])) { if ($_POST['source']=="Flatbed") { - $scanprog = $scanimage; +// $scanprog = $scanimage; +$scanprog = $scanadf; //TEMP SET ALL TO ADF } else { $scanprog = $scanadf; } } else { - $scanprog = $scanimage; +// $scanprog = $scanimage; +$scanprog = $scanadf; //TEMP SET ALL TO ADF } // are we being called as a result of a scan or just initial page view? if (isset($_POST['scan'])) { @@ -127,7 +131,7 @@ $filename = date($date_format); } // do it! - $process = proc_open($scanprog . " -d " . $_POST['device'] . " --output-file " . $scans_dir . $filename . "-%04d --source " . $_POST['source'] . " --mode " . $_POST['mode'] . " --resolution " . $sResolution . " -l " . $_POST['l'] . " -t " . $_POST['t'] . " -x " . $sX . " -y " . $_POST['y'], $descriptorspec, $pipes, $cwd, $env); + $process = proc_open($scanprog . " -d " . $_POST['device'] . " --output-file " . $scans_dir . $filename . "-%04d --source " . $_POST['source'] . " --mode " . $_POST['mode'] . " --resolution " . $pResolution . " -l " . $_POST['l'] . " -t " . $_POST['t'] . " -x " . $pX . " -y " . $_POST['y'], $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { $errors = stream_get_contents($pipes[2]); $output = stream_get_contents($pipes[1]); @@ -149,7 +153,7 @@ //exec($convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg"); // make a (multi-page) pdf file from the scanned pnm files // we have to set density to match the scan resolution and then calculate the width to pixels in order to make the pdf correct - exec($convert . ' -density ' . $sResolution . ' -page ' . $sX . ' ' . $path . ' ' . $scans_dir . $filename . '.pdf'); + exec($convert . ' -density ' . $pResolution . ' ' . $path . ' ' . $scans_dir . $filename . '.pdf'); // $output = $convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg"; // $output .= ($convert . " " . $path . " " . $scans_dir . $filename . ".pdf"); echo "Scan Successful!"; @@ -180,5 +184,62 @@ ?> + + +