This patch adds recognition of PNG and JPEG files to mgetty+sendfax.
The extensions .tiff, .text are also now correctly recognised, and a help
is given of known file types when the user is promped to enter the type.

Volker Kuhlmann, 10 Mar 2003


--- /usr/bin/faxspool.orig	2002-09-11 08:20:39.000000000 +1200
+++ /usr/bin/faxspool	2003-03-21 11:05:13.000000000 +1200
@@ -19,6 +19,12 @@
 #   .g3  -> raw G3 fax data
 #   .lj  -> HP Laserjet PCL4 (use hp2pbm)
 #   .xwd -> xwindow-dump (by xwd program, use xwdtopnm)
+#   .gif
+#   .tiff
+#   .png -> Portable Network Graphics
+#             (uses pngtopnm | ppmtopgm | pgmtopbm | pbm2g3 )
+#   .jpeg -> Joint Photographic Experts Group
+#             (uses jpegtopnm | ppmtopgm | pgmtopbm | pbm2g3 )
 #
 # ChangeLog:
 #  3.6.93: use dvips instead of dvialw now (GD)
@@ -26,6 +32,12 @@
 #  3.10.93: use "hp2hig3" for hp-pcl4-files (cl)
 # 19.10.93: phone directories (caz)
 # $Log: faxspool.in,v $
+# Revision 4.20  2003/03/21 10:48:00  Volker Kuhlmann
+# Add handling of jpeg + .text
+#
+# Revision 4.19  2003/03/11 00:48:00  Volker Kuhlmann
+# Add handling of png
+#
 # Revision 4.18  2000/10/11 10:06:41  gert
 # fix combination of "copy_sorce" and "faxspool.rules" (command line destroyed)
 #
@@ -203,7 +215,7 @@
 # problem1: conversion always via ppm, pgm
 # problem2: multipage TIFFs
 #
-fs_cvt_tif()
+fs_cvt_tiff()
 {
     REDUCE="cat"
     test X$3 = X-n && REDUCE="pnmscale -yscale 0.5"
@@ -217,6 +229,40 @@
 }
 
 #
+# convert PNG file
+# problem1: conversion always via ppm, pgm
+#
+fs_cvt_png()
+{
+    REDUCE="cat"
+    test X$3 = X-n && REDUCE="pnmscale -yscale 0.5"
+
+    pngtopnm $1 |\
+	pnmscale -xysize 1728 2000 |\
+	$REDUCE |\
+	ppmtopgm |\
+	pgmtopbm |\
+	pbm2g3 >$2.001
+}
+
+#
+# convert JPEG file
+# problem1: conversion always via ppm, pgm
+#
+fs_cvt_jpeg()
+{
+    REDUCE="cat"
+    test X$3 = X-n && REDUCE="pnmscale -yscale 0.5"
+
+    jpegtopnm $1 |\
+	pnmscale -xysize 1728 2000 |\
+	$REDUCE |\
+	ppmtopgm |\
+	pgmtopbm |\
+	pbm2g3 >$2.001
+}
+
+#
 # convert HP laserjet input files
 # needs Chris Lewis' hp2pbm package (ftp.uunet.ca)
 #
@@ -721,13 +767,17 @@
 	*.ppm)	format="ppm";;
 	*.t)	format="ascii";;
 	*.txt)	format="ascii";;
+	*.text)	format="ascii";;
 	*.asc)	format="ascii";;
 	*.lj)   format="lj" ;;
 	*.pcl)  format="lj" ;;
 	*.xwd)	format="xwd";;
 	*.gif)	format="gif";;
-	*.tif)	format="tif";;
-	*.tiff)	format="tif";;
+	*.tif)	format="tiff";;
+	*.tiff)	format="tiff";;
+	*.png)	format="png";;
+	*.jpeg) format="jpeg";;
+	*.jpg)	format="jpeg";;
     esac
 
 # if we don't know the file type now, let's look for some more
@@ -755,6 +805,7 @@
 	    *"commands text"*)	format="ascii" ;;
 	    *"c program text"*)	format="ascii" ;;
 	    *"script text"*)	format="ascii" ;;
+	    *"ISO-8859 text"*)	format="ascii" ;;
 	    *PBM*)		format="pbm" ;;
 	    *PGM*)		format="pgm" ;;
 	    *PPM*)		format="ppm" ;;
@@ -764,7 +815,10 @@
 	    *PCL*)	format="lj" ;;
 	    *postscript*)	format="ps" ;;
 	    *PostScript*)	format="ps" ;;
-	    *TIF*)		format="tif" ;;
+	    *TIF*)		format="tiff" ;;
+	    *PNG*)		format="png" ;;
+	    *JPEG*)		format="jpeg" ;;
+	    *JFIF*)		format="jpeg" ;;
 	esac
 
 # if file told us, it's an ascii text, or if we still don't know, try
@@ -780,8 +834,10 @@
 		P2*|P5*)	format="pgm" ;;
 		P3*|P6*)	format="ppm" ;;
 		GIF*)		format="gif" ;;	# hmmm.
-	    	II*)		format="tif" ;;
-		MM*)		format="tif" ;;
+	    	II*)		format="tiff" ;;
+		MM*)		format="tiff" ;;
+		?PNG)		format="png" ;;
+		# JPEG has "^......JFIF"
 	    esac
 	fi
 #
@@ -802,6 +858,9 @@
 #
     if [ -z "$format" ] ; then
 	$echo "$file: cannot determine file format (extend source)" >&2
+	$echo >&2 "Currently recognised:"
+	$echo >&2 \
+ "   g3 ps pdf dvi pbm pgm ppm ascii lj xwd gif tiff png jpeg"
 #
 # if stdin is a tty, ask the user for the file type
 #
@@ -830,7 +889,7 @@
     else
 	case $format in
 	    ps | ascii | pbm | pgm | ppm |\
-	    g3 | dvi   | lj  | xwd | gif | tif | pdf) 
+	    g3 | dvi   | lj  | xwd | gif | tiff | png | pdf | jpeg) 
 		    fs_cvt_$format $file $target $normal_res
 		    ;;    
 	    *) $echo "$0: no internal filter for format '$format!' found" >&2 
