2002.08.14 20:42 "diskless TIFF conversion for HylaFAX", by Lee Howard

Hello all. I'm still working on getting HylaFAX to fax MMR (COMPRESSION_CCITTFAX4) image files. I have two catches left to resolve. First, the image is re-imaged for "page-chopping" so as to remove large areas of whitespace at the bottom of a page. Secondly, the image is again re-imaged to place the tagline (the identification line required by the FCC) on the page.

HylaFAX currently has routines to pagechop and image the tagline for MH and MR (COMPRESSION_CCITTFAX3) images. As was discussed previously on this list, building on to those routines to include MMR funcitonality would be extremely time-consuming, and given that HylaFAX is linked to libtiff, it would be wise to just use the libtiff functions to convert the image to MH or MR and then back to MMR after pagechopping or imaging the tagline (i.e., the functions that drive tiffcp).

This same approach will also facilitate HylaFAX to do "on-the-fly" image conversion to send a fax, for example, in MR even when the image file was in MH.

So that's what I'd like to do. Only, I don't want to involve any disk activity. So, I think that calling on tiffcp directly is out of the question. On large-volume or slow systems the constant disk activity from conversions would cause problems, most certainly.

If anyone could give me some pointers on how to handle this, I would appreciate it.

HylaFAX reads the image into a "data" variable like this:

u_char* data = new u_char[totdata+ts];
u_int off = ts; // skip tag line slop area
for (strip = 0; strip < nstrips; strip++) {
    uint32 sbc = stripbytecount[strip];
    if (sbc > 0 && TIFFReadRawStrip(tif, strip, data+off, sbc) >= 0)
        off += (u_int) sbc;
}

totdata is u_long and is the total byte length of the image strips. ts is the byte length required to image the tagline.

My question is, now that the image is in the data variable, how can I convert data between MH, MR, and MMR compression formats? The geometry is known, so that's not a problem.

I looked at the source for libtiff's tiffcp, and it appears to simply TIFFRead* and then TIFFWrite*. Does simply reading in data and then writing out data accomplish the conversion? Can this be done without disk activity?

Thanks.

Lee Howard
HylaFAX developer