Update index.php
This commit is contained in:
parent
a6471ace85
commit
56224c4504
53
index.php
53
index.php
@ -102,19 +102,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<?php
|
||||||
|
// initialize scanned files directory path
|
||||||
|
$scans_dir = $app_dir . $scan_dir;
|
||||||
<?php
|
// set post variables
|
||||||
// initialize scanned files directory path
|
if(isset($_POST['sResolution'])) { $pResolution = $_POST['sResolution']; };
|
||||||
$scans_dir = $app_dir . $scan_dir;
|
if(isset($_POST['sX'])) { $pX = $_POST['sX']; };
|
||||||
|
// decide to use scanimage if Flatbed or scanadf if ADF
|
||||||
// set post variables
|
if (isset($_POST['source'])) {
|
||||||
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") {
|
if ($_POST['source']=="Flatbed") {
|
||||||
$scanprog = $scanimage;
|
$scanprog = $scanimage;
|
||||||
} else {
|
} else {
|
||||||
@ -123,9 +118,8 @@ if (isset($_POST['source'])) {
|
|||||||
} else {
|
} else {
|
||||||
$scanprog = $scanimage;
|
$scanprog = $scanimage;
|
||||||
}
|
}
|
||||||
|
// are we being called as a result of a scan or just initial page view?
|
||||||
// are we being called as a result of a scan or just initial page view?
|
if (isset($_POST['scan'])) {
|
||||||
if (isset($_POST['scan'])) {
|
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
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
|
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
||||||
@ -133,8 +127,8 @@ if (isset($_POST['scan'])) {
|
|||||||
);
|
);
|
||||||
$cwd = '/tmp';
|
$cwd = '/tmp';
|
||||||
$env = array();
|
$env = array();
|
||||||
// append to filename if set, otherwise date only
|
// append to filename if set, otherwise date only
|
||||||
if (isset($_POST['filenaming'])) {
|
if (isset($_POST['filenaming'])) {
|
||||||
if (empty($_POST['filenaming'])) {
|
if (empty($_POST['filenaming'])) {
|
||||||
$filename = date($date_format);
|
$filename = date($date_format);
|
||||||
} else {
|
} else {
|
||||||
@ -143,8 +137,7 @@ if (isset($_POST['filenaming'])) {
|
|||||||
} else {
|
} else {
|
||||||
$filename = date($date_format);
|
$filename = date($date_format);
|
||||||
}
|
}
|
||||||
|
// do it!
|
||||||
// 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 " . $sResolution . " -l " . $_POST['l'] . " -t " . $_POST['t'] . " -x " . $sX . " -y " . $_POST['y'], $descriptorspec, $pipes, $cwd, $env);
|
||||||
if (is_resource($process)) {
|
if (is_resource($process)) {
|
||||||
$errors = stream_get_contents($pipes[2]);
|
$errors = stream_get_contents($pipes[2]);
|
||||||
@ -164,26 +157,20 @@ if (isset($_POST['filenaming'])) {
|
|||||||
foreach ($inputFiles as $file) {
|
foreach ($inputFiles as $file) {
|
||||||
$path .= "pnm:" . $scans_dir . $file;
|
$path .= "pnm:" . $scans_dir . $file;
|
||||||
}
|
}
|
||||||
//exec($convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg");
|
//exec($convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg");
|
||||||
// make a (multi-page) pdf file from the scanned pnm files
|
// 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
|
// 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 ' . $sResolution . ' -page ' . $sX . ' ' . $path . ' ' . $scans_dir . $filename . '.pdf');
|
||||||
|
// $output = $convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg";
|
||||||
// $output = $convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg";
|
|
||||||
// $output .= ($convert . " " . $path . " " . $scans_dir . $filename . ".pdf");
|
// $output .= ($convert . " " . $path . " " . $scans_dir . $filename . ".pdf");
|
||||||
echo "Scan Successful!";
|
echo "Scan Successful!";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "Scan Failed! No pages were scanned. Is there a document in the scanner?";
|
echo "Scan Failed!";
|
||||||
}
|
}
|
||||||
ob_flush();
|
ob_flush();
|
||||||
echo "";
|
echo "";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1 pure-u-md-1-2">
|
<div class="pure-u-1 pure-u-md-1-2">
|
||||||
<h2>Previous Document Scans (PDF)</h2>
|
<h2>Previous Document Scans (PDF)</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user