1999.08.12 13:58 "Re: TIFF to JPEG file - how?", by Tom Lane
I want to write a JPEG file from a JPEG'd TIFF image without decompressing and recompressing.
If so, how? I'm trying to adapt code in tiffsplit.c or tiffcp.c, but I'm unclear on how to write the raw data in a JPEG conventional way. If I adapt the code in cjpeg.c (from the JPEG distribution) I'm unclear how to splice in the TIFF strip-oriented code (i.e. convert the raw TIFF data from TIFFReadRawStrip() to the JSAMPIMAGE sample expected by jpeg_write_raw_data()).
If you did such a thing then you wouldn't have produced a lossless copy; jpeg_write_raw_data() only avoids colorspace conversion & resampling, not DCT.
For single-strip images you really don't have to do anything except extract the raw contents of the strip and write it out to a file. I think you can persuade libtiff to give you back the physical contents of a strip without passing it through any decompressor, but I forget how.
Multi-strip images would be considerably harder. If they're all compressed at the same quality setting then in theory you could do it (you'd need a souped-up version of jpegtran); but the spec allows for varying compression settings between strips/tiles, which cannot be losslessly converted to a single 10918-1 JPEG datastream...
regards, tom lane
organizer, Independent JPEG Group