Passa al contenuto principale

4. Un esempio di file immagine TIFF

Di seguito è riportato un esempio di ciò che potrebbe contenere un file TIFF per una singola immagine codificata MMR (G4), compressa a 400 dpi per circa 100K byte. Viene dapprima presentato uno schema generico, seguito da un elenco esadecimale più dettagliato.

4.A. File di esempio​

I commenti si trovano a destra e sono preceduti da un punto e virgola. Si noti che i tag devono essere ordinati in base ai codici dei tag.

0:, IFDADDR: e STRIP0: sono indirizzi all'interno del file e indicano il numero di byte a partire dall'inizio del 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 questo esempio c'è una sola striscia. Si noti che, se ce ne fosse più di una, la specifica TIFF non richiede che siano in un ordine particolare. Le strisce possono essere presentate in qualsiasi ordine e i lettori TIFF devono usare StripOffsets per individuarle.

Inoltre, il documento TIFF raccomanda di non affidarsi ai valori predefiniti dei tag.

4.B. Elenco esadecimale dettagliato​

Tutti gli offset e i valori sono rappresentati in esadecimale, a eccezione delle stringhe ASCII, che sono racchiuse tra virgolette doppie. Si ricordi che i Value Offset devono essere sempre un numero pari, poiché il valore a cui puntano deve trovarsi sempre su un confine di parola a 16 bit.

Le voci nella colonna Name sono di riferimento e non fanno parte effettivamente del file 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]

NOTA: poiché in questo esempio c'è un'unica striscia, esiste un solo conteggio per StripByteCounts e un solo offset per StripOffsets. Pertanto, ciascuno di essi occupa soltanto 4 byte e rientra nel Value Offset invece di essere puntato.