summaryrefslogtreecommitdiff
path: root/doc/functions/TIFFReadDirectory.rst
blob: ec3aebda49bdc467d6482f927096e78c0cada10a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
TIFFReadDirectory
=================

Synopsis
--------

.. highlight:: c

::

    #include <tiffio.h>

.. c:function:: int TIFFReadDirectory(TIFF* tif)

.. c:function:: int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);

Description
-----------

Read the next directory in the specified file and make it the current
directory. Applications only need to call :c:func:`TIFFReadDirectory`
to read multiple subfiles in a single TIFF file—(the first directory
in a file is automatically read when :c:func:`TIFFOpen` is called.

Notes
-----

If the library is compiled with :c:macro:`STRIPCHOP_SUPPORT` enabled, then
images that have a single uncompressed strip or tile of data are
automatically treated as if they were made up of multiple strips or tiles of
approximately 8 kilobytes each. This operation is done only in-memory; it does
not alter the contents of the file. However, the construction of the "chopped
strips" is visible to the application through the number of strips [tiles]
returned by :c:func:`TIFFNumberOfStrips` [:c:func:`TIFFNumberOfTiles`].

Return values
-------------

If the next directory was successfully read, 1 is returned. Otherwise, 0 is
returned if an error was encountered, or if there are no more directories to
be read.

Diagnostics
-----------

All error messages are directed to the :c:func:`TIFFError` routine.
All warning messages are directed to the :c:func:`TIFFWarning` routine.

``Seek error accessing TIFF directory``:

  An error occurred while positioning to the location of the
  directory.

``Wrong data type %d for field "%s"``:

  The tag entry in the directory had an incorrect data type.
  For example, an ``ImageDescription`` tag with a ``SHORT``
  data type.

``TIFF directory is missing required "%s" field``:

  The specified tag is required to be present by the TIFF
  5.0 specification, but is missing.
  The directory is (usually) unusable.

``%s: Rational with zero denominator``:

  A directory tag has a ``RATIONAL`` value whose denominator is zero.

``Incorrect count %d for field "%s" (%lu, expecting %lu); tag ignored``:

  The specified tag's count field is bad.
  For example, a count other than 1 for a ``SubFileType`` tag.

``Cannot handle different per-sample values for field "%s"``:

  The tag has ``SamplesPerPixel`` values and they are not all the same; e.g.
  ``BitsPerSample``.  The library is unable to handle images of this sort.

``Count mismatch for field "%s"; expecting %d, got %d``:

  The count field in a tag does not agree with the number expected by the library.
  This should never happen, so if it does, the library refuses to
  read the directory.

``Invalid TIFF directory; tags are not sorted in ascending order``:

  The directory tags are not properly sorted as specified
  in the TIFF 5.0 specification.  This error is not fatal.

``Ignoring unknown field with tag %d (0x%x)``:

  An unknown tag was encountered in the directory;
  the library ignores all such tags.

``TIFF directory is missing required "ImageLength" field``:

  The image violates the specification by not having a necessary field.
  There is no way for the library to recover from this error.

``TIFF directory is missing required "PlanarConfig" field``:

  The image violates the specification by not having a necessary field.
  There is no way for the library to recover from this error.

``TIFF directory is missing required "StripOffsets" field``:

  The image has multiple strips, but is missing the tag that
  specifies the file offset to each strip of data.
  There is no way for the library to recover from this error.

``TIFF directory is missing required "TileOffsets" field``:

  The image has multiple tiles, but is missing the tag that
  specifies the file offset to each tile of data.
  There is no way for the library to recover from this error.

``TIFF directory is missing required "StripByteCounts" field``:

  The image has multiple strips, but is missing the tag that
  specifies the size of each strip of data.
  There is no way for the library to recover from this error.

``TIFF directory is missing required "StripByteCounts" field, calculating from imagelength``:

  The image violates the specification by not having a necessary field.
  However, when the image is comprised of only one strip or tile, the
  library will estimate the missing value based on the file size.

``Bogus "StripByteCounts" field, ignoring and calculating from imagelength``:

  Certain vendors violate the specification by writing zero for
  the StripByteCounts tag when they want to leave the value
  unspecified.
  If the image has a single strip, the library will estimate
  the missing value based on the file size.

See also
--------

:doc:`TIFFOpen` (3tiff),
:doc:`TIFFWriteDirectory` (3tiff),
:doc:`TIFFSetDirectory` (3tiff),
:doc:`libtiff` (3tiff),