
Thread
2005.02.25 10:50 "Re: [Tiff] How to get a thumbnail View for a single page TIFF file.", by Joris Van Damme
Priyanshu,
if I comment out this function call from the code "TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff);" ( its present in the function defination of ShowThumbnail() function ) and set the page no i want to view as thumbnail by function TIFFSetDirectory().
I'm not sure what the problem is here, I'm not sure what code you are referring to, nor what your intentions are.
- TIFFSetDirectory, http://www.remotesensing.org/libtiff/man/TIFFSetDirectory.3t.html, is used to browse to a page, ie to set the current page pointer. If, for instance, you need to view the fifth image in the linked list of images that is in the opened TIFF file, you'll use this function, with page index parameter 4.
- TIFFSetField, http://www.remotesensing.org/libtiff/man/TIFFSetField.3t.html, is a totally other bag of cookies, in that it is used in writing to a TIFF file, not in reading from it. When you write a TIFF file, you use this function to specify particular tags. Specifying the TIFFTAG_SUBIFD with TIFFSetField is a special case, see http://www.asmail.be/msg0055226761.html for its exact meaning.
I am getting 2 pages tiff file where first page is the thumbnail for the required page and second page is the actuall page for which i want the thumbnail view.
Sometimes, tiff writer apps do that. It's evil, for three reasons
- If an image and its reduced size verion(s) are written in the upper level of linked IFDs (= images, in this case), the upper level is logically used. There is no longer a logically consistent way to add other images to the file.
- TIFF readers have little or no indication of what they are dealing with here. A human can easilly enough identify the reduced size version(s), but it is hard and errorprone for a TIFF reader to see that these two would-be-pages relate, and how they relate. Thus, TIFF readers cannot make good use of the reduced size version(s), which defeats their purpose.
- This scheme ignore specification supplement 1 on SubIFDs (http://partners.adobe.com/public/developer/en/tiff/TIFFPM6.pdf).
This being said, I often encounter such a TIFF. Apart from grumbling and nagging, an possibly throwing stuff at a person that happens to be nearby, there's nothing much we can do about it... ;-) The only logical thing code can do, is treat it as a regular two page TIFF, instead of a single page TIFF that is enriched with a thumbnail or something, since it cannot detect it is not a regular two page TIFF with two logically independent pages.
Or perhaps not... If there are two pages in a file, you could see if the NewSubfileType and/or the SubfileType tag (http://www.awaresystems.be/imaging/tiff/tifftags/newsubfiletype.html and http://www.awaresystems.be/imaging/tiff/tifftags/subfiletype.html) have certain values, and try to deduct something from that. It's not the logical thing to do, and has the added dissadvantage that one has to try to read two IFDs to make sense of the first one, but it could perhaps be regarded the most 'reality-compatible' way to deal with it. This does not however invalidate the above mentioned reasons why the situation is evil, and TIFF writers should be made not to produce this kind of TIFFs and use the SubIFDs tag instead.
i am not able to find relevent information abt tag no 330 also.. if any one has some thing relevent plz post it or mail it to me.
There's a tag search page, http://www.awaresystems.be/imaging/tiff/tifftags/search.html, where you can enter just about anything like tag name, or, in this case, decimal tag number. Searching for 330 there, yields the SubIFDs tag page http://www.awaresystems.be/imaging/tiff/tifftags/subifds.html. On that page, there's a short explanation, and a link to the specification supplement 1 that I referred to earlier. That specification suppelement fully defines the SubIFDs tag.
Best regards;
Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html