| 1 |
TIFFWriteDirectory |
| 2 |
================== |
| 3 |
|
| 4 |
Synopsis |
| 5 |
-------- |
| 6 |
|
| 7 |
.. highlight:: c |
| 8 |
|
| 9 |
:: |
| 10 |
|
| 11 |
#include <tiffio.h> |
| 12 |
|
| 13 |
.. c:function:: int TIFFWriteDirectory(TIFF* tif) |
| 14 |
|
| 15 |
.. c:function:: int TIFFRewriteDirectory(TIFF* tif) |
| 16 |
|
| 17 |
.. c:function:: int TIFFCheckpointDirectory(TIFF* tif) |
| 18 |
|
| 19 |
.. c:function:: void TIFFSetWriteOffset(TIFF* tif, toff_t off) |
| 20 |
|
| 21 |
.. c:function:: int TIFFWriteCheck(TIFF* tif, int tiles, const char* module) |
| 22 |
|
| 23 |
Description |
| 24 |
----------- |
| 25 |
|
| 26 |
:c:func:`TIFFWriteDirectory` will write the contents of the current |
| 27 |
directory (IFD) to the file and setup to create a new directory (IFD) |
| 28 |
using :c:func:`TIFFCreateDirectory`. |
| 29 |
Applications only need to call :c:func:`TIFFWriteDirectory` |
| 30 |
when writing multiple subfiles (images) to a single TIFF file. |
| 31 |
This is called "multi-page TIFF" or "multi-image TIFF" |
| 32 |
(see :doc:`/multi_page`). |
| 33 |
:c:func:`TIFFWriteDirectory` is automatically called by |
| 34 |
:c:func:`TIFFClose` and :c:func:`TIFFFlush` to write a modified |
| 35 |
directory if the file is open for writing. |
| 36 |
|
| 37 |
The :c:func:`TIFFRewriteDirectory` function operates similarly to |
| 38 |
:c:func:`TIFFWriteDirectory`, but can be called with directories |
| 39 |
previously read or written that already have an established location |
| 40 |
in the file. It will rewrite the directory, but instead of placing it |
| 41 |
at its old location (as :c:func:`TIFFWriteDirectory` would, if the size |
| 42 |
of the directory has not grown) it will |
| 43 |
place them at the end of the file, correcting the pointer from the |
| 44 |
preceding directory or file header to point to it's new location. This |
| 45 |
is particularly important in cases where the size of the directory and |
| 46 |
pointed to data has grown, so it won't fit in the space available at the |
| 47 |
old location. |
| 48 |
|
| 49 |
The :c:func:`TIFFCheckpointDirectory` writes the current state of the |
| 50 |
tiff directory into the file to make what is currently in the file |
| 51 |
readable. Unlike :c:func:`TIFFWriteDirectory`, |
| 52 |
:c:func:`TIFFCheckpointDirectory` does not free up the directory data |
| 53 |
structures in memory, so they can be updated (as strips/tiles are |
| 54 |
written) and written again. Reading such a partial file you will at |
| 55 |
worst get a tiff read error for the first strip/tile encountered that |
| 56 |
is incomplete, but you will at least get all the valid data in the file |
| 57 |
before that. When the file is complete, just use |
| 58 |
:c:func:`TIFFWriteDirectory` as usual to finish it off cleanly. |
| 59 |
|
| 60 |
The :c:func:`TIFFSetWriteOffset` sets the current write offset. |
| 61 |
This should only be used to set the offset to a known previous location |
| 62 |
(very carefully), or to 0 so that the next write gets appended to the end |
| 63 |
of the file. |
| 64 |
|
| 65 |
The :c:func:`TIFFWriteCheck` verify file is writable and that the directory |
| 66 |
information is setup properly. In doing the latter we also "freeze" |
| 67 |
the state of the directory so that important information is not changed. |
| 68 |
|
| 69 |
Return values |
| 70 |
------------- |
| 71 |
|
| 72 |
1 is returned when the contents are successfully written to the file. |
| 73 |
Otherwise, 0 is returned if an error was encountered when writing |
| 74 |
the directory contents. |
| 75 |
|
| 76 |
Diagnostics |
| 77 |
----------- |
| 78 |
|
| 79 |
All error messages are directed to the :c:func:`TIFFErrorExtR` routine. |
| 80 |
|
| 81 |
``"Error post-encoding before directory write"``: |
| 82 |
|
| 83 |
Before writing the contents of the current directory, any pending data are |
| 84 |
flushed. This message indicates that an error occurred while doing this. |
| 85 |
|
| 86 |
``"Error flushing data before directory write"``: |
| 87 |
|
| 88 |
Before writing the contents of the current directory, any pending data are |
| 89 |
flushed. This message indicates that an error occurred while doing this. |
| 90 |
|
| 91 |
``"Cannot write directory, out of space"``: |
| 92 |
|
| 93 |
There was not enough space to allocate a temporary area for the directory |
| 94 |
that was to be written. |
| 95 |
|
| 96 |
``"Error writing directory count"``: |
| 97 |
|
| 98 |
A write error occurred when writing the count of fields in the directory. |
| 99 |
|
| 100 |
``"Error writing directory contents"``: |
| 101 |
|
| 102 |
A write error occurred when writing the directory fields. |
| 103 |
|
| 104 |
``"Error writing directory link"``: |
| 105 |
|
| 106 |
A write error occurred when writing the link to the next directory. |
| 107 |
|
| 108 |
``Error writing data for field "%s"``: |
| 109 |
|
| 110 |
A write error occurred when writing indirect data for the specified field. |
| 111 |
|
| 112 |
``"Error writing TIFF header"``: |
| 113 |
|
| 114 |
A write error occurred when re-writing header at the front of the file. |
| 115 |
|
| 116 |
``"Error fetching directory count"``: |
| 117 |
|
| 118 |
A read error occurred when fetching the directory count field for |
| 119 |
a previous directory. |
| 120 |
This can occur when setting up a link to the directory that is being |
| 121 |
written. |
| 122 |
|
| 123 |
``"Error fetching directory link"``: |
| 124 |
|
| 125 |
A read error occurred when fetching the directory link field for |
| 126 |
a previous directory. |
| 127 |
This can occur when setting up a link to the directory that is being |
| 128 |
written. |
| 129 |
|
| 130 |
See also |
| 131 |
-------- |
| 132 |
|
| 133 |
:doc:`TIFFquery` (3tiff), |
| 134 |
:doc:`TIFFOpen` (3tiff), |
| 135 |
:doc:`TIFFCreateDirectory` (3tiff), |
| 136 |
:doc:`TIFFCustomDirectory` (3tiff), |
| 137 |
:doc:`TIFFSetDirectory` (3tiff), |
| 138 |
:doc:`TIFFReadDirectory` (3tiff), |
| 139 |
:doc:`TIFFError` (3tiff), |
| 140 |
:doc:`/multi_page`, |
| 141 |
:doc:`libtiff` (3tiff) |