From f144f67562e3638284c2f4ece7428e0ed4430327 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Tue, 31 Dec 2013 00:00:00 +0100 Subject: [PATCH] (2013-12-31) --- code/scans.php | 21 ++++++++++++++++++--- config.php | 5 ++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/scans.php b/code/scans.php index 36a99dd..d6f8a02 100644 --- a/code/scans.php +++ b/code/scans.php @@ -8,6 +8,8 @@ function Scan($device,$resolution,$format,$destFileBase){ global $ScanImage; global $PNMtoJPEG; global $PNMtoPNG; + global $PNMtoPS; + global $PStoPDF; $DestFile=$PreviewDir.$destFileBase; $Command=$ScanImage." -d ".$device. @@ -15,21 +17,35 @@ function Scan($device,$resolution,$format,$destFileBase){ if($format=="jpg"){ $DestFile.=".jpg"; $Command.=" | {$PNMtoJPEG} --quality=100 > ".$DestFile; + $Scan=shell_exec($Command); } if($format=="png"){ $DestFile.=".png"; $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; } function CleanUp(){ global $PreviewDir; + $Command="rm -rf ".$PreviewDir."*.pnm"; + $Delete=shell_exec($Command); $Command="rm -rf ".$PreviewDir."*.png"; $Delete=shell_exec($Command); $Command="rm -rf ".$PreviewDir."*.jpg"; $Delete=shell_exec($Command); + $Command="rm -rf ".$PreviewDir."*.pdf"; + $Delete=shell_exec($Command); } function MoveToDest($origFile){ @@ -73,7 +89,6 @@ if(RequestParm("btnScan",false)){ $baseName="Scan-".date("Y-m-d_H_i_s"); $DestFile=Scan($Scanner,$Resolution,$Format,$baseName); CropImage($DestFile); - CropImage($DestFile); }else{ $baseName="Scan-".date("Y-m-d_H_i_s"); $DestFile=Scan($Scanner,$Resolution,$Format,$baseName); @@ -88,7 +103,7 @@ echo '
'."\n"; DrawFieldInfo("Scanner",$SaneScanner); DrawFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution); DrawFieldCombo("Format","ddlFormat",$Formats,$Format); -//DrawFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz); +DrawFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz); DrawButton("Scan","btnScan"); if($DestFile!=null){ $DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8"); diff --git a/config.php b/config.php index ee4c77e..3905529 100644 --- a/config.php +++ b/config.php @@ -7,6 +7,8 @@ $ScanImage = "/usr/bin/scanimage"; $PNMtoJPEG = "/usr/bin/pnmtojpeg"; $PNMtoPNG = "/usr/bin/pnmtopng"; +$PNMtoPS = "/usr/bin/pnmtops"; +$PStoPDF = "/usr/bin/ps2pdf14"; $ImageMagik = "/usr/bin/convert"; // Destination dirs @@ -29,7 +31,8 @@ $Resolution=200; // Formats $Formats=array( "PNG"=>"png", - "JPEG/JPG"=>"jpg" + "JPEG/JPG"=>"jpg", + "PDF"=>"pdf" ); $Format="png";