4. A Sample TIFF Image File
Below is a sample of what might be in a TIFF file for an MMR (G4) encoded single image which is about 100K bytes compressed at 400 dpi. A generic outline is given first, followed by a more detailed hex listing.
4.A. Sample File
Comments are to the right and are preceded by a semicolon. Note that tags must be sorted in order of the tag codes.
0:, IFDADDR:, and STRIP0: are addresses within the file and denote the number of bytes from the beginning of the file.
Header:
0: Byte Order= hex 4D4D ;first bytes of the file, from
;most significant bit to least
;significant (big endian)
Version= 42 (hex 002A) ;Must be 42
First IFD= IFDADDR ;Address of first (and only) IFD
Image File Directory (the only one in this example):
IFDADDR:
IFD Entry Count= 24 ;(NOT A TAG) Count of
; Number of IFD Entries
NewSubFileType= 0
ImageWidth= 3400 ;8.5 inches at 400 dpi
ImageLength= 4400 ;11 inches at 400 dpi
BitsPerSample= 1 ;Bi-Level
Compression= 4 ;MMR
Photometric-
Interpretation= 0
DocumentName= "LAMap1"
ImageDescription= "A map of Los Angeles"
Make= "Fujitsu"
Model= "M3093E"
StripOffsets= <STRIP0> ;There is only one strip in
;this example. However, note
;that strips can be in any
;order. (Offsets are from the
;beginning of the TIFF file.)
SamplesPerPixel= 1 ;Bi-Level
RowsPerStrip= 4400 ;Entire image in 1 strip
StripByteCounts= <COUNT0> ;Byte count of entire
;compressed image
XResolution= 400/1
YResolution= 400/1
XPosition= 0/1 ;position of left side of image
YPosition= 0/1 ;position of top of image
Group4Options= hex 00000002 ;bit 1 on means uncompressed
;mode MAY be used
ResolutionUnit= 2 ;Inches
Software= "Xionics"
DateTime= "1990:10:05 15:00:00"
Artist= "Joe Pro"
HostComputer= "Tardis.Isi.Edu"
Next IFD Pointer= hex 00000000 ;(NOT A TAG) Indicates no
; more IFDs in this file
Image Data:
<STRIP0>: <actual compressed image data>
[end of TIFF file]
In this example there is only one strip. Note that if there were more than one, the TIFF specification does not require them to be in any particular order. Strips may be given in any order and TIFF readers must use the StripOffsets to locate them.
Also, the TIFF document recommends not relying on the default values of the tags.
4.B. Detailed Hex Listing
All offsets and values are represented by hex except for ASCII strings which are double quoted. Remember that Value Offsets must always be an even number since the value it points to must always be on a 16-bit word boundary.
Entries in the Name column are for reference and are not actually a part of the TIFF file.
Offset Name Value
---- ------------------- -------------------------------------
Header (first byte is Offset 0):
0000 Byte Order 4D4D
0002 Version 002A
0004 1st. IFD pointer 00000010
IFD (IFDADDR from above is 0010 here):
0010 Entry Count 0018
0012 NewSubFileType 00FE 0004 00000001 00000000
001E ImageWidth 0100 0004 00000001 00000D48
002A ImageLength 0101 0004 00000001 00001130
0036 BitsPerSample 0102 0003 00000001 00010000
0042 Compression 0103 0003 00000001 00040000
004E Photometric Interp. 0106 0003 00000001 00000000
005A DocumentName 010D 0002 00000007 00000136
0066 ImageDescription 010E 0002 00000015 0000013E
0072 Make 010F 0002 00000008 00000154
007E Model 0110 0002 00000007 0000015C
008A StripOffsets 0111 0004 00000001 000001A8
0096 SamplesPerPixel 0115 0003 00000001 00010000
00A2 RowsPerStrip 0116 0004 00000001 00001130
00AE StripByteCounts 0117 0004 00000001 <COUNT0>
00BA XResolution 011A 0005 00000001 00000164
00C6 YResolution 011B 0005 00000001 00000164
00D2 XPosition 011E 0005 00000001 0000016C
00DE YPosition 011F 0005 00000001 0000016C
00EA Group4Options 0125 0004 00000001 00000002
00F6 ResolutionUnit 0128 0003 00000001 00020000
0102 Software 0131 0002 00000008 00000174
010E DateTime 0132 0002 00000014 0000017C
011A Artist 013B 0002 00000008 00000190
0126 HostComputer 013C 0002 0000000F 00000198
0132 Next IFD Pointer 00000000
Fields Offsets Point to:
0136 DocumentName "LAMap1"
013E ImageDescription "A map of Los Angeles"
0154 Make "Fujitsu"
015C Model "M3093E"
0164 X,Y Resolution 00000190 00000001
016C X,Y Position 00000000 00000001
0174 Software "Xionics"
017C DateTime "1990:10:05 15:00:00"
0190 Artist "Joe Pro"
0198 HostComputer "Tardis.Isi.Edu"
Image Data (<STRIP0> from above is here 01A8)
01A8 Compressed Data for single strip, of length <COUNT0> bytes
[end of TIFF file]
NOTE: Since in this example there is only a single strip, there is only one count for StripByteCounts and one offset for StripOffsets. Thus, each of these only takes 4 bytes and will fit in the Value Offset instead of being pointed to.