2008.03.12 07:07 "[Tiff] encapsulate jpeg to TIFF without de-compressing and re-compressing", by Zhang Weiwu

2008.03.17 18:13 "Re: [Tiff] encapsulate jpeg to TIFF without de-compressing andre-compressing", by Gerben Vos

Hi. I had been looking for an way to// //encapsulate an existing jpeg file to TIFF format, without de-compress it first and re-compress it again.

Yes, you can do this. Basically, you just set the ImageWidth and ImageHeight tags to the size of the JPEG, and write the JPEG data in a single strip with TIFFWriteRawstrip(). Also set the other necessary TIFF tags, of course.

If you don't know the image size, you must scan the JPEG for the marker that indicates it. (I don't know which they are, sorry. We have some code - proprietary, sorry - that converts PDF to TIFF in a similar way, and we can take the size information from the PDF...)

Also, you may want to scan the JPEG for the "APPE" marker (0xFF 0xEE) to find out if a colour transformation from RGB or YUV has taken place, and to set the Photometric tag accordingly. Similarly for the SOF0 marker (0xFF 0xC0) which contains the subsampling values (see TIFF Technote 2) and the YCbCrSubsampling tag.

A draft copy of the JPEG spec (but very usable) can be found at http://www.jpeg.org/public/fcd14492.pdf.

Gerben Vos.


Please respond to the mailing list, not to me directly.