From af11db934669d80faedf97709097b6f4c8b55b10 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Sun, 28 Jun 2015 02:27:29 +0200 Subject: [PATCH] Faster PDF generation using only ImageMagik --- code/scanner.php | 25 +++++-------------------- config.php | 4 +--- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/code/scanner.php b/code/scanner.php index 02341ea..6b75a45 100644 --- a/code/scanner.php +++ b/code/scanner.php @@ -24,8 +24,7 @@ function Scan($device,$resolution,$format,$size,$destFileBase){ global $ScanImage; global $PNMtoJPEG; global $PNMtoPNG; - global $PNMtoPS; - global $PStoPDF; + global $ImageMagik; $DestFile=$PreviewDir.$destFileBase; $Command=$ScanImage." -d ".$device. @@ -57,26 +56,12 @@ function Scan($device,$resolution,$format,$size,$destFileBase){ $Scan=ExecCommand($Command); } if($format=="pdf"){ - $DestFile2=$DestFile.".pnm"; - $Command.=" > {$DestFile2}"; + $DestFile2=$DestFile.".jpg"; + $Command.=" | {$PNMtoJPEG} --quality=100 > ".$DestFile2; $Scan=ExecCommand($Command); - $DestFile.=".pdf"; - $Command="cat {$DestFile2} | {$PNMtoPS}"; - if($size=="A4"){ - $Command.=" -width=8.3 -height=11.7 "; - } - if($size=="A5Port"){ - $Command.=" -width=5.8 -height=8.3 "; - } - if($size=="A5Land"){ - $Command.=" -width=8.3 -height=5.8 "; - } - if($size=="Letter"){ - $Command.=" -width=8.5 -height=11 "; - } - $Command.=" | {$PStoPDF} - {$DestFile}"; - $Convert=ExecCommand($Command); + $Command=$ImageMagik." ".$DestFile2." ".$DestFile; + $Scan=ExecCommand($Command); } return $DestFile; } diff --git a/config.php b/config.php index aaa22ef..2133630 100644 --- a/config.php +++ b/config.php @@ -7,8 +7,6 @@ $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 @@ -34,7 +32,7 @@ $Formats=array( "JPEG/JPG"=>"jpg", "PDF"=>"pdf" ); -$Format="png"; +$Format="pdf"; // Size $Sizes=array(