HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-users] Patch to faxrcvd: FILETYPE=png



Hi,

here is a patch against faxrcvd (v.1.6)

It makes FILETYPE=png possible.

If there are several pages in a fax, multiple
images are created. The images are created
with "convert" (imageMagick).

 Thomas

-- 
Thomas Güttler, TBZ-PARIV GmbH, Bernsdorfer Str. 210-212, 09126 Chemnitz
Tel.: 0371/5221217 Fax:  0371/5221216



--- bin/faxrcvd-orig	2003-07-17 12:37:05.000000000 +0200
+++ bin/faxrcvd	2004-03-01 18:10:31.000000000 +0100
@@ -220,6 +220,50 @@
 	     $PS2PDF -g$GW\x$GL -r$RW\x$RL $FILE.ps $FILE.pdf 2>/dev/null
 	     base64 $FILE.pdf 2>/dev/null
 	     $RM -f $FILE.ps $FILE.pdf 2>/dev/null
+         elif [ "$FILETYPE" = "png" ]; then
+             #tguettler 2003-07-25:
+             LOG=/tmp/fax.log
+             echo "---- converting FILE: $FILE FILENAME: $FILENAME" `date` \
+                   >> $LOG
+             
+             yres=`identify -format "%y" $FILE | head -1 | cut -d ' ' -f1 ` 
+             #Different Resolution for Y-Axis?
+             echo "Resolution: '$yres'" >> $LOG
+             if [ "$yres" == "98" ]; then
+                SCALE="-scale 100%x207.154%"
+                echo "Scaling image" >> $LOG
+             else
+                SCALE=""
+                echo "Not scaling image" >> $LOG
+             fi
+             #SCALE: for fax with low resolution (x_res != y_res)
+             #-map netscape:  for konqueror
+             #-background black  for netscape 4.7
+             convert -map netscape: \
+                     -background black \
+                     -monochrome \
+                     $SCALE \
+                     -density 72x72 \
+                     $FILE $FILENAME.png >> $LOG 2>&1
+             let "i=0"
+             for file in $FILENAME.png*;
+             do 
+               let "i=i+1"
+               new_file=$FILENAME.$i.png
+               echo "file: $file new_file: $new_file" >> $LOG 
+               mv $file $new_file >> $LOG 2>&1
+               file=$new_file
+               echo "Content-Type: image/png; name=\"$file\""
+               echo "Content-Description: FAX document"
+               echo "Content-Transfer-Encoding: base64"
+               echo "Content-Disposition: attachment; filename=\"$file\""
+               echo ""
+               base64 $file 2>>$LOG
+               echo ""
+               echo "--$MIMEBOUNDARY"
+               rm -f $file 2>/dev/null
+            done
+            echo "<<< end converting $FILE " `date` >> $LOG
 	 else #  default as Postscript
 	     echo "Content-Type: application/postscript; name=\"$FILENAME.ps\""
 	     echo "Content-Description: FAX document"



Project hosted by iFAX Solutions