跳到主要内容

4. 一个 TIFF 图像文件示例

下面是一个 TIFF 文件中可能包含的内容示例, 该 TIFF 文件用于一幅采用 MMR (G4) 编码的单幅图像, 该图像在 400 dpi 下压缩后约为 100K 字节. 首先给出总体轮廓, 随后给出更详细的十六进制清单.

4.A. 示例文件​

注释位于右侧, 前面有一个分号. 请注意, 标签必须按标签代码的顺序排序.

0:, IFDADDR: 和 STRIP0: 是文件内的地址, 表示从文件开头起的字节数.

   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]

在此示例中只有一个条带. 请注意, 如果有多个条带, TIFF 规范并不要求它们按任何特定顺序排列. 条带可以按任意顺序给出, TIFF 读取器必须使用 StripOffsets 来定位它们.

此外, TIFF 文档建议不要依赖标签的默认值.

4.B. 详细十六进制清单​

除用双引号括起的 ASCII 字符串外, 所有偏移量和值都用十六进制表示. 请记住, 值偏移量 (Value Offset) 必须始终为偶数, 因为它指向的值必须始终位于 16 位字边界上.

Name 列中的条目仅供参考, 实际上并不属于 TIFF 文件的一部分.

   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]

注意: 由于此示例中只有一个条带, 因此 StripByteCounts 只有一个计数值, StripOffsets 只有一个偏移量. 所以, 它们各自只占 4 个字节, 可以直接放入 Value Offset 中, 而不必通过指针指向.