When using the incoming fax-to-email feature of FreePBX, it is useful to have
the email include a reduced resolution gif (or jpeg) image so you can quickly
identify fax-spam from legitimate faxes. Most email clients will display an
attached image inline without having to explicitly open it. I find that opening
a PDF attachment takes several seconds which gets very annoying if many junk
faxes come in.
This patch requires the "convert" command from the ImageMagick
package, so this command needs to be run.
yum install ImageMagick
This is the diff to /var/lib/asterisk/bin/fax-process.pl
< my $enc_gif="";
98,104d96
<
< open GIF, "convert -resize '50%' -monochrome -delay 300 ${file}[0,1] gif:- |";
< $buf = "";
< while (read(GIF, $buf, 60*57)) {
< $enc_gif .= encode_base64($buf);
< }
< close GIF;
128d119
< my $len_gif = length $enc_gif;
147c138
< A Fax has been received by the fax gateway, and is attached to this message.
---
> A Fax has been recieved by the fax gateway, and is attached to this message.
151,155d141
< Content-Type: image/gif; name=\"thumb.gif\"
< Content-Transfer-Encoding: base64
<
< $enc_gif
< --$boundary
I suppose this patch could
have been done by creating a new command line option for fax-process.pl, but
then the extensions.conf would have to be changed as well. I will attach my
modified version including the above changes.
The default ImageMagick? behavior is to create an animated gif of all the
pages with no delay between frames, so the pages fly by so fast you can't read
them. The parameter "-delay 300" makes each page display for
3 seconds in the animated gif.
Considering the purpose of the gif is to give the recipient an idea of what the
fax is before opening the pdf, it would be useful to only include the first page
or two. You can use square-bracket syntax to specify a page range, and it seems
to be forgiving if not all the pages are there. I changed the "$file"
to "${file}[0,1]" in the command line so only the first two pages
appear in the gif.
I also corrected the spelling of "received".
This is a complete and working patch. Work remains to commit this to trunk and
to include ImageMagick? in the base install if this patch is accepted.