Faster PDF generation using only ImageMagik

This commit is contained in:
2015-06-28 02:27:29 +02:00
parent da860617b5
commit af11db9346
2 changed files with 6 additions and 23 deletions

View File

@@ -24,8 +24,7 @@ function Scan($device,$resolution,$format,$size,$destFileBase){
global $ScanImage; global $ScanImage;
global $PNMtoJPEG; global $PNMtoJPEG;
global $PNMtoPNG; global $PNMtoPNG;
global $PNMtoPS; global $ImageMagik;
global $PStoPDF;
$DestFile=$PreviewDir.$destFileBase; $DestFile=$PreviewDir.$destFileBase;
$Command=$ScanImage." -d ".$device. $Command=$ScanImage." -d ".$device.
@@ -57,26 +56,12 @@ function Scan($device,$resolution,$format,$size,$destFileBase){
$Scan=ExecCommand($Command); $Scan=ExecCommand($Command);
} }
if($format=="pdf"){ if($format=="pdf"){
$DestFile2=$DestFile.".pnm"; $DestFile2=$DestFile.".jpg";
$Command.=" > {$DestFile2}"; $Command.=" | {$PNMtoJPEG} --quality=100 > ".$DestFile2;
$Scan=ExecCommand($Command); $Scan=ExecCommand($Command);
$DestFile.=".pdf"; $DestFile.=".pdf";
$Command="cat {$DestFile2} | {$PNMtoPS}"; $Command=$ImageMagik." ".$DestFile2." ".$DestFile;
if($size=="A4"){ $Scan=ExecCommand($Command);
$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);
} }
return $DestFile; return $DestFile;
} }

View File

@@ -7,8 +7,6 @@
$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
@@ -34,7 +32,7 @@ $Formats=array(
"JPEG/JPG"=>"jpg", "JPEG/JPG"=>"jpg",
"PDF"=>"pdf" "PDF"=>"pdf"
); );
$Format="png"; $Format="pdf";
// Size // Size
$Sizes=array( $Sizes=array(