2007.10.05 01:18 "[Tiff] Looking for some help or sample code to put a jpeg file into a 'jpeg-in-tiff' file.", by S. Campbell

2007.10.05 05:56 "Re: [Tiff] Looking for some help or sample code to put a jpeg file into a 'jpeg-in-tiff' file.", by Joris Van Damme


I'm would appreciate a little help, or direction in taking a standard jpeg file and wrapping that in a standard Tiff technote#2 file.

That should be pretty straightforward.

You first need to see what's in the JPEG. It'll likely contain YCbCr, with certain subsampling values and of course particular image dimensions. You then create a TIFF file, with a single strip, given those image dimensions and you mention the correct Subsampling values and the photometric YCbCr. For the single strip data, you just paste the JPEG.

This procedure is not entirely correct. For example, the JPEG data will likely contain JFIF elements, possibly even a thumbnail, and restart markers. All of these should not really be present in the JPEG data inside the TIFF file. But they are most naturally ignored by a decoder anyway. You could take this one step further, though, by eliminating JFIF data and sorts, and using the restart markers to split the actual compressed data that can next be rewrapped to form individual strips if they're on appropriate boundaries.

This procedure is not entirely fail-proof either. Certain subsampling values that can exist inside a JPEG file, are not legit inside a TIFF file. But these are rarely used, and even if they're not legit inside a TIFF file they're still perfectly unambigious so robust decoders should still be able to handle them.

It's possible though very rare for a JPEG to include real RGB data, or CMYK or YCCK data. If it's RGB or CMYK, you can still make a legit TIFF out of it, simply by using another appropriate photometric inside the TIFF and not bugging with subsampling values. If it's YCCK, you're out of luck.

Does this help at all, or are you looking for more, like, say, code-snippet stuff?

Best regards,

Joris Van Damme
Download your free TIFF tag viewer for windows here: