# Performing online image conversion

You can convert the image characteristics of a file offline before transmitting the fax, or online while transmitting and receiving a fax. Because image conversion consumes significant processor time, you may want to perform file conversions offline to conserve CPU resources for processing events during an active fax session.

NaturalFax's receive and transmit parameter structures, NFX_RECEIVE_PARMS and NFX_TRANSMIT_PARMS, contain image format parameters for encoding, resolution, and page width. These parameters are used with the OTFmode (on-the-fly) parameter to determine the format of the image being transmitted or received. Refer to Image format characteristics for more information.

Refer to NFX_TRANSMIT_PARMS or NFX_RECEIVE_PARMS for valid OTFmode parameters. When NaturalFax is receiving a fax, NFX_DOC_PARMS contains the image format parameters that determine how the image is stored.

NFX_RECEIVE_PARMS contains the badlineaction parameter, which controls how the receiving fax terminal manages bad lines of data. Refer to NFX_RECEIVE_PARMS for valid badlineaction parameters.

This topic presents the following information:

- Image conversion during fax transmission

- Image conversion during fax reception

- Generating TIFF-S files on receive

## Image conversion during fax transmission

NaturalFax uses the parameters from NFX_TRANSMIT_PARMS and the capabilities of the remote fax terminal to determine the image format used during a fax transmission.

The first step in determining the final transmission format is based on the capabilities of the transmitting and receiving fax terminals. The remote receiver announces its capabilities in the DIS
frame. NaturalFax uses the image format parameters in the NFX_TRANSMIT_PARMS structure and the capabilities of the receiver to choose the initial transmission format. The initial transmission format is set to the NFX_TRANSMIT_PARMS value if the remote receiver can support it; otherwise it is set to the nearest value that the receiver supports.

The next step in determining the transmission format is based on the value of OTFmode in NFX_TRANSMIT_PARMS. The format of the stored file is compared with the initial transmission format, and conversion takes place according to the following criteria:

If OTFmode is set to... | And the stored file format... | Then...
NFX_OTF_NEVER | Requires capabilities less than or equal to the initial transmission format | The stored image format is selected as the final transmission format. No image conversion is performed.
NFX_OTF_NEVER | Requires more advanced capabilities than can be provided by the initial transmission format | The fax session fails, and NaturalFax returns NFXEVN_SESSION_DONE with the error NFXERR_INCOMPATIBLE_RECEIVER. No file is sent, since the system cannot satisfy the needs of the receiver without performing a conversion. No image conversion is performed.
NFX_OTF_ONLY_IF_FAIL | Requires capabilities less than or equal to the initial transmission format | The stored file format is selected as the final transmission format. No image conversion is performed.
NFX_OTF_ONLY_IF_FAIL | Requires more advanced capabilities than can be provided by the initial transmission format | The file is converted to match the initial transmission format. The initial transmission format is selected as the final transmission format. NaturalFax performs on-the-fly image conversion.
NFX_OTF_ALWAYS | Does not match the initial transmission format, it will be converted. This mode will always use the encoding format characteristics specified by the initial transmission format. | There will only be a conversion for resolution and page width if it is necessary to support a lesser transmission capability. NaturalFax performs on-the-fly image conversion if required.

After the decision is made, the final transmission format is sent back to the receiver in the DCS
frame. The application can retrieve the final transmission format by interrogating the NFX_DOC_STATUS and NFX_FAX_STATUS data structures.

For the best image quality, an application should use the best formatting that the receiving fax machine can support. Set NFX_TRANSMIT_PARMS to use NFX_ENCODE_MMR, NFX_RESOLUTION_SUPER_HIGH, and NFX_PAGE_WIDTH_A3 to use the best capabilities of the receiving fax machine.

OTFmode can be set to NFX_OTF_ONLY_IF_FAIL to minimize the host execution time, or to NFX_OTF_ALWAYS to minimize transmission time. Checking and replacement of bad lines is performed when OTFmode is set to NFX_OTF_ONLY_IF_FAIL or NFX_OTF_ALWAYS.

The following illustration shows the image format decision process during fax transmission:

## Image conversion during fax reception

NaturalFax uses the parameters from NFX_RECEIVE_PARMS and the remote fax terminal's capabilities to determine the image format stored during a fax receive operation. This process includes the following steps:

Step | Action
1 | When NaturalFax acts as the receiving fax terminal, it sends the image format values from NFX_RECEIVE_PARMS to the remote transmitter in a DIS frame to announce the receiver's capabilities to the transmitter.
2 | The transmitter sends back a DCS frame with the final transmission format. The remote transmitter controls the choice of the final transmission format.
3 | Once the final transmission format is determined, the application uses the values from NFX_DOC_PARMS and the value for OTFmode in NFX_RECEIVE_PARMS to determine how the incoming image data is actually stored. Conversion only takes place if OTFmode is set to NFX_OTF_ALWAYS. Otherwise, the file is stored in the format received. If OTFmode is set to NFX_OTF_ALWAYS, the NFX_DOC_PARMS values for the document determine the final storage format. A conversion from lower to higher resolution, and from narrower to wider pages is performed if specified. Using NFX_OTF_ALWAYS is appropriate when your application requires a specific image format, and there are sufficient host CPU resources to support on-the-fly conversion. To use the minimum host CPU resources when receiving a fax, accept the highest quality the sender can provide. Save the image directly to a file without performing conversion using NXF_ENCODE_MMR, NFX_RESOLUTION_SUPER_HIGH, NFX_PAGE_WIDTH_A3, and NFX_OTF_NEVER in NFX_RECEIVE_PARMS.
4 | To retrieve the final storage format after the document is received, examine the NFX_DOC_STATUS or NFX_FAX_STATUS structures.

The following illustration shows how the stored image format is selected during a fax receive operation:

## Generating TIFF-S files on receive

When receiving an image to be used in future T.37 operations, the application can choose to:

- Ensure that the image is transmitted in TIFF-S format by advertising only TIFF-S compatible capabilities, which minimizes CPU resources

- Receive the image in the fastest means possible, and use the OTFmode to convert the image to TIFF-S format after reception.

The following table summarizes how the document will be transmitted, as determined by the OTFmode, when NFX_RECEIVE_PARMS.ENCODING = TIFF_S.

OTFmode | Advertised parameters
--- | ---
NFX_OTF_NEVER | 1D encoding Low resolution A4 page width
NFX_OTF_ALWAYS | MMR encoding (if ECM is enabled) or MR (if ECM is disabled) Low resolution A4 page width