Fax Server: Better compatibility with current libtiff-tools.

This commit is contained in:
fusionate 2020-11-05 16:08:27 -07:00
parent 5fa52feefe
commit 4f29228768
2 changed files with 9 additions and 42 deletions

View File

@ -115,7 +115,6 @@
//download the fax
if ($_GET['a'] == "download") {
session_cache_limiter('public');
//test to see if it is in the inbox or sent directory.
if ($_GET['type'] == "fax_inbox") {
if (file_exists($fax_dir.'/'.$_GET['ext'].'/inbox/'.$_GET['filename'])) {
@ -349,19 +348,12 @@
$page_height = 11.7;
$page_size = 'a4';
}
//generate pdf (a work around, as tiff2pdf improperly inverts the colors)
$cmd_tif2pdf = "tiff2pdf -i -u i -p ".$page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax_temp.'/'.$file_name.".pdf ".$dir_fax.'/'.$file_name.".tif";
//echo $cmd_tif2pdf."<br>";
//generate pdf from tif
$cmd_tif2pdf = "tiff2pdf -u i -p ".$page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax.'/'.$file_name.".pdf ".$dir_fax.'/'.$file_name.".tif";
exec($cmd_tif2pdf);
chdir($dir_fax_temp);
$cmd_pdf2tif = "gs -q -sDEVICE=tiffg3 -r".$gs_r." -g".$gs_g." -dNOPAUSE -sOutputFile=".$file_name."_temp.tif -- ".$file_name.".pdf -c quit";
//echo $cmd_pdf2tif."<br>";
exec($cmd_pdf2tif); //convert pdf to tif
@unlink($dir_fax_temp.'/'.$file_name.".pdf");
$cmd_tif2pdf = "tiff2pdf -i -u i -p ".$page_size." -w ".$page_width." -l ".$page_height." -f -o ".$dir_fax.'/'.$file_name.".pdf ".$dir_fax_temp.'/'.$file_name."_temp.tif";
//echo $cmd_tif2pdf."<br>";
exec($cmd_tif2pdf);
@unlink($dir_fax_temp.'/'.$file_name."_temp.tif");
//clean up temporary files, if any
if (file_exists($dir_fax_temp.'/'.$file_name.'.pdf')) { @unlink($dir_fax_temp.'/'.$file_name.'.pdf'); }
if (file_exists($dir_fax_temp.'/'.$file_name.'.tif')) { @unlink($dir_fax_temp.'/'.$file_name.'.tif'); }
}
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {

View File

@ -369,7 +369,9 @@ if (!function_exists('fax_split_dtmf')) {
$fax_name = str_replace("=", "_", $fax_name);
$attachment_file_name = $_files['name'][$index];
rename($dir_fax_temp.'/'.$attachment_file_name, $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
if ($attachment_file_name != $fax_name.'.'.$fax_file_extension) {
rename($dir_fax_temp.'/'.$attachment_file_name, $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
}
unset($attachment_file_name);
if (!$included) {
@ -660,41 +662,14 @@ if (!function_exists('fax_split_dtmf')) {
@unlink($tif_file);
}
//generate pdf (a work around, as tiff2pdf was improperly inverting the colors)
//generate pdf from tif
$cmd = 'tiff2pdf -u i -p '.$fax_page_size.
' -w '.$page_width.
' -l '.$page_height.
' -f -o '.
correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf').' '.
correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'.tif');
// echo($cmd . "<br/>\n");
exec($cmd);
chdir($dir_fax_temp);
//$cmd = gs_cmd("-q -sDEVICE=psmono -r".$gs_r." -g".$gs_g." -dNOPAUSE -dBATCH -dSAFER -sOutputFile=".correct_path($fax_instance_uuid).".pdf -- ".correct_path($fax_instance_uuid).".pdf -c quit");
// echo($cmd . "<br/>\n");
//exec($cmd);
//convert pdf to tif
$cmd = gs_cmd('-q -sDEVICE=tiffg32d -r'.$gs_r.' -g'.$gs_g.' -dBATCH -dPDFFitPage -dNOPAUSE -sOutputFile='.
correct_path($fax_instance_uuid.'_temp.tif').
' -- '.$fax_instance_uuid.'.pdf -c quit');
// echo($cmd . "<br/>\n");
exec($cmd);
@unlink($dir_fax_temp.'/'.$fax_instance_uuid.".pdf");
$cmd = 'tiff2pdf -u i -p '.$fax_page_size.
' -w '.$page_width.
' -l '.$page_height.
' -f -o '.
correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf').' '.
correct_path($dir_fax_temp.'/'.$fax_instance_uuid.'_temp.tif');
// echo($cmd . "<br/>\n");
exec($cmd);
@unlink($dir_fax_temp.'/'.$fax_instance_uuid."_temp.tif");
}
else {
if (!$included) {