(2013-12-31)
This commit is contained in:
@@ -8,6 +8,8 @@ function Scan($device,$resolution,$format,$destFileBase){
|
|||||||
global $ScanImage;
|
global $ScanImage;
|
||||||
global $PNMtoJPEG;
|
global $PNMtoJPEG;
|
||||||
global $PNMtoPNG;
|
global $PNMtoPNG;
|
||||||
|
global $PNMtoPS;
|
||||||
|
global $PStoPDF;
|
||||||
|
|
||||||
$DestFile=$PreviewDir.$destFileBase;
|
$DestFile=$PreviewDir.$destFileBase;
|
||||||
$Command=$ScanImage." -d ".$device.
|
$Command=$ScanImage." -d ".$device.
|
||||||
@@ -15,21 +17,35 @@ function Scan($device,$resolution,$format,$destFileBase){
|
|||||||
if($format=="jpg"){
|
if($format=="jpg"){
|
||||||
$DestFile.=".jpg";
|
$DestFile.=".jpg";
|
||||||
$Command.=" | {$PNMtoJPEG} --quality=100 > ".$DestFile;
|
$Command.=" | {$PNMtoJPEG} --quality=100 > ".$DestFile;
|
||||||
|
$Scan=shell_exec($Command);
|
||||||
}
|
}
|
||||||
if($format=="png"){
|
if($format=="png"){
|
||||||
$DestFile.=".png";
|
$DestFile.=".png";
|
||||||
$Command.=" | {$PNMtoPNG} > ".$DestFile;
|
$Command.=" | {$PNMtoPNG} > ".$DestFile;
|
||||||
|
$Scan=shell_exec($Command);
|
||||||
|
}
|
||||||
|
if($format=="pdf"){
|
||||||
|
$DestFile2=$DestFile.".pnm";
|
||||||
|
$Command.=" > {$DestFile2}";
|
||||||
|
$Scan=shell_exec($Command);
|
||||||
|
|
||||||
|
$DestFile.=".pdf";
|
||||||
|
$Command="cat {$DestFile2} | {$PNMtoPS} | {$PStoPDF} - {$DestFile}";
|
||||||
|
$Convert=shell_exec($Command);
|
||||||
}
|
}
|
||||||
$Scan=shell_exec($Command);
|
|
||||||
return $DestFile;
|
return $DestFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CleanUp(){
|
function CleanUp(){
|
||||||
global $PreviewDir;
|
global $PreviewDir;
|
||||||
|
$Command="rm -rf ".$PreviewDir."*.pnm";
|
||||||
|
$Delete=shell_exec($Command);
|
||||||
$Command="rm -rf ".$PreviewDir."*.png";
|
$Command="rm -rf ".$PreviewDir."*.png";
|
||||||
$Delete=shell_exec($Command);
|
$Delete=shell_exec($Command);
|
||||||
$Command="rm -rf ".$PreviewDir."*.jpg";
|
$Command="rm -rf ".$PreviewDir."*.jpg";
|
||||||
$Delete=shell_exec($Command);
|
$Delete=shell_exec($Command);
|
||||||
|
$Command="rm -rf ".$PreviewDir."*.pdf";
|
||||||
|
$Delete=shell_exec($Command);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MoveToDest($origFile){
|
function MoveToDest($origFile){
|
||||||
@@ -73,7 +89,6 @@ if(RequestParm("btnScan",false)){
|
|||||||
$baseName="Scan-".date("Y-m-d_H_i_s");
|
$baseName="Scan-".date("Y-m-d_H_i_s");
|
||||||
$DestFile=Scan($Scanner,$Resolution,$Format,$baseName);
|
$DestFile=Scan($Scanner,$Resolution,$Format,$baseName);
|
||||||
CropImage($DestFile);
|
CropImage($DestFile);
|
||||||
CropImage($DestFile);
|
|
||||||
}else{
|
}else{
|
||||||
$baseName="Scan-".date("Y-m-d_H_i_s");
|
$baseName="Scan-".date("Y-m-d_H_i_s");
|
||||||
$DestFile=Scan($Scanner,$Resolution,$Format,$baseName);
|
$DestFile=Scan($Scanner,$Resolution,$Format,$baseName);
|
||||||
@@ -88,7 +103,7 @@ echo '<form id="frmMain" method="GET" action="index.php">'."\n";
|
|||||||
DrawFieldInfo("Scanner",$SaneScanner);
|
DrawFieldInfo("Scanner",$SaneScanner);
|
||||||
DrawFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution);
|
DrawFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution);
|
||||||
DrawFieldCombo("Format","ddlFormat",$Formats,$Format);
|
DrawFieldCombo("Format","ddlFormat",$Formats,$Format);
|
||||||
//DrawFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz);
|
DrawFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz);
|
||||||
DrawButton("Scan","btnScan");
|
DrawButton("Scan","btnScan");
|
||||||
if($DestFile!=null){
|
if($DestFile!=null){
|
||||||
$DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8");
|
$DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8");
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
$ScanImage = "/usr/bin/scanimage";
|
$ScanImage = "/usr/bin/scanimage";
|
||||||
$PNMtoJPEG = "/usr/bin/pnmtojpeg";
|
$PNMtoJPEG = "/usr/bin/pnmtojpeg";
|
||||||
$PNMtoPNG = "/usr/bin/pnmtopng";
|
$PNMtoPNG = "/usr/bin/pnmtopng";
|
||||||
|
$PNMtoPS = "/usr/bin/pnmtops";
|
||||||
|
$PStoPDF = "/usr/bin/ps2pdf14";
|
||||||
$ImageMagik = "/usr/bin/convert";
|
$ImageMagik = "/usr/bin/convert";
|
||||||
|
|
||||||
// Destination dirs
|
// Destination dirs
|
||||||
@@ -29,7 +31,8 @@ $Resolution=200;
|
|||||||
// Formats
|
// Formats
|
||||||
$Formats=array(
|
$Formats=array(
|
||||||
"PNG"=>"png",
|
"PNG"=>"png",
|
||||||
"JPEG/JPG"=>"jpg"
|
"JPEG/JPG"=>"jpg",
|
||||||
|
"PDF"=>"pdf"
|
||||||
);
|
);
|
||||||
$Format="png";
|
$Format="png";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user