TIFF and LibTiff Mail List Archive


2003.04.28 19:44 "Registering a tag with Adobe", by Robert S. Kissel
2003.04.29 04:26 "Re: Registering a tag with Adobe", by Chris Cox
2003.04.29 16:12 "Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo
2003.04.29 16:50 "RE: Newbie Question (StripOffsets/StripByteCount)", by Belshan, James
2003.04.29 17:58 "RE: Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo
2003.04.29 19:51 "RE: Newbie Question (StripOffsets/StripByteCount)", by Carter John-jcarte01
2003.04.30 15:08 "RE: Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo
2003.04.30 15:19 "RE: Newbie Question (StripOffsets/StripByteCount)", by Carter John-jcarte01

2003.04.30 15:19 "RE: Newbie Question (StripOffsets/StripByteCount)", by Carter John-jcarte01

sorry about that yea your right, i was getting confused with the way I have it coded.

if(count * size_of_type) > 4)
        its an offset
        its a value

re compression: just an example of casting, ive seen the compression type variable being mis-intepreted because it wasn't cast, I sure this holds true for other tags.


-----Original Message-----

From: Harring Figueiredo []

Sent: 30 April 2003 16:09 To: Carter John-jcarte01;

Subject: RE: Newbie Question (StripOffsets/StripByteCount)

 Hi John,

Thanks for the reply. I am not sure about your condition: ( count * size_of_type >= 4).

if count * size_of_tag is == 4, then it fits on a long value. Therefore; it will not be an offset.

The TIFF 6.0 spec (page 15) says, ".. Value Offset contains the Value instead
of pointing to the Value if and only if the Value fits into 4 bytes. ..."

 If it is == 4 bytes, it clearly fits, thus it will not be an offset, but the
value itself. (Anyone cares to commnet on this ?)

I am not sure about the compression, since I will not decompress it. I will just read the strips and move/copy into another area. The StripBytecount will have the correct number of bytes to read since it is "after any compression."

Thanks again for the email.


--- Carter John-jcarte01 <> wrote:

I think I'm right in making a correction to your
I think it should be ( count * size_of_type >= 4)
rather than

( count * size_of_type > 4)

I made that mistake too, and it took me a while to spot it.

also (on slightly related point)
don't forget to cast the ifd_entry.value_offset

such as compression below, switching on ifd_entry.value_offset directly can give you some strange results.

                case COMPRESSION:
                        tiff_data->compression = (TIFF_SHORT)ifd_entry.value_offset;
                                        case 1:

                                                printf("        Image is not compressed\n");
                                        case 2:
                                                printf("        Uses 1d Huffman run length encoding\n");
                                        case 3:
                                                printf("        T4 Bilevel compression\n");
                                        case 4:
                                                printf("        T6 Bilevel compression\n");
                                        case 5:
                                                printf("        LZW compression\n");
                                        case 6:
                                                printf("        JPEG compression\n");
                                        case 32773:
                                                printf("        PackBits on Raster image data\n");
                                                printf("        No case for compression type %d\n",
                                                printf("        in file %s %d\n",__FILE__,__LINE__);


From: Harring Figueiredo []
Sent: 29 April 2003 18:59
To: Belshan, James (E52);

Subject: RE: Newbie Question (StripOffsets/StripByteCount)


Thanks for the reply.

I understand the offset concept when the data does not fit on the LONG value field ( count * size_of_type > 4) means that the value holds the offset. In fact, I already have a Java TIFF dump that matches exactly with the C counterpart ( except that mine still does not handle multipage).

Thanks again for clarifying how to get the strip data. I will do the way you are saying.


--- "Belshan, James (E52)" <> wrote:

Hope I don't say anything that's incorrect... But here goes.

How you interpret the ValueOffset (VO) field depends on how much and what type of numbers are in the tag. If all of the tag data will fit in the VO field, it puts it there, otherwise VO is a LONG pointer to the data location. If that's the case, then you would move to that point in the file, and read the number and type of Values specified in the tag. In your case, since the StipOffset and StripByteCount tags only have 1 value, it fits in the VO field. So you would move to byte 8 in the file and read 11544 bytes of data to get your image.

If you had more than 1 strip, (say 5 strips) then StripOffsets would have 5 values (and so wouldn't fit in the VO field), and the StripOffsets VO would point you where to go to read 5 LONG offsets. You would then go to EACH of the 5 byte locations and read the proper # of bytes for that strip. StripByteCounts would also have 5 values to tell how long each of the 5 strips are.

Page 16 of the TIFF Rev 6.0 tells you that the VO field is 4 bytes long, so it will fit 2 SHORTS or 1 LONG. An example of a tag that doesn't fit in the VO field is the RATIONAL resolutions that tiffdump is showing you. RATIONALS are 8 bytes, and so don't fit in the VO field. tiffdump is actually following an offset in the VO, and reading 8 bytes to make the RATIONAL.

Hope this helps,