Python Fax - Retrieve Inbound Fax Image

Download the Python fax code samples and library.

In this sample, you can learn how to retrieve an image for an inbound (received) fax with Python. This is done using the GetImageChunk method.

This Python fax snippet demonstrates how to retrieve a fax image in multiple chunks (the chunk size is configurable).

Use the GetList method to retrieve the fax message ID and file size (both are needed in order to retrieve the fax image).

"""
A simple script to fetch a chunk of a received fax image
using the InterFAX GetImageChunk SOAP API call.
"""
from interfax import client
 
print 'Testing GetImageChunk...'
c = client.InterFaxClient('USERNAME','PASSWORD') # Enter your Interfax username/password here
 
messageId = 12345678 # Enter the ID of the inbound message to be read
messageSize = 2931   # Size in bytes of the inbound message. This value
                     # is returned by method GetList, which should be run
                     # before this one
result = c.getImageChunk( messageId, True, messageSize, 0, "/tmp/%d.tif" % messageId )
print '   GetImageChunk returned with code %d' % result