2003.04.29 16:12 "Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo

2003.04.29 16:12 "Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo

Folks, I have the folowing image:

Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 11552 (0x2d20) next 0 (0)
ImageWidth (256) SHORT (3) 1 <1864>
ImageLength (257) SHORT (3) 1 <728>
Compression (259) SHORT (3) 1 <4>
Photometric (262) SHORT (3) 1 <0>
StripOffsets (273) LONG (4) 1 <8>
Orientation (274) SHORT (3) 1 <1>
RowsPerStrip (278) SHORT (3) 1 <728>
StripByteCounts (279) LONG (4) 1 <11544>
XResolution (282) RATIONAL (5) 1 <>
YResolution (283) RATIONAL (5) 1 <>
PlanarConfig (284) SHORT (3) 1 <1>

In the above image, does StripByteCounts(11544) mean that this is the byte count of the only strip on the image, or does it mean that this is an offset to the byte count?

I am very confused with these 2 tags (StripOffsets and StripByteCount) as they REALLY do NOT conform with the description of "Image Entry" on the TIFF spec. i.e.


  1. Does the type of StripOffsets apply to the "value" field or to the list of offsets ? (I.e. TYPE short means that Value is SHORT, or that all the list of offsets are of type SHORT ? Or both ?
  2. If the image has a single strip (like the one above) does the Value point to the Strip directly or does it still point the a single LONG value that points to the offset of the strip ?

I have to write a Java program (please, don't laugh -- I have suffered enough :P) that adds tiff tags to an existing image. These two tags are giving me headaches.

What I am doing is, recontrcuting a set tags from the image, adding them to the set of tags I am adding to the image, copying the image data (thus the question above), and writing the image back to a buffer again. Is that a good approach?

NOTE: I parse a bunch of single images, and add tags to them and add them to a muiltipage tiff.

If anyone has a java program that does similar stuff or if there is a JNI wrapper that does that, please give me a poiter.

YES - I must write it in java because My boss says so and Java is the solution to the world's problem around where I work.

Thanks for any help.