4
The following described approach to managing tag extensions has been
5
mostly superceeded since libtiff 3.6.0. The described approach requires
6
internal knowledge of the libtiff API and tends to be very fragile
7
in the face of libtiff upgrades.
9
Please read over the html/addingtags.html in preference to the below
14
==================================
16
Client module for adding to LIBTIFF tagset
17
-------------------------------------------
23
In the past, users of the "libtiff" package had to modify the
24
source code of the library if they required additional private tags
25
or codes not recognized by libtiff. Thus, whenever
26
a new revision of libtiff came out the client would have to
27
perform modifications to six or seven different files to re-install
30
The latest versions of libtiff now provide client software new routines,
31
giving them the opportunity to install private extensions at runtime,
32
rather than compile-time. This means that the client may encapsulate
33
all of their private tags into a separate module, which need only
34
be recompiled when new versions of libtiff are released; no manual
35
editing of files is required.
40
The mechanism for overriding the tag access has been enabled with
41
a single new routine, which has the following calling sequence:
43
TIFFExtendProc old_extender;
45
old_extender = TIFFSetTagExtender(tag_extender);
47
which must be called prior to opening or creating TIFF files.
49
This routine sets a static pointer to the user-specified function
50
<tag_extender>, which in turn is called by TIFFDefaultDirectory(),
51
just after the usual TIFFSetField() and TIFFGetField() methods
52
are defined, and just before the compression tag is set. It also
53
returns a pointer to the previously-defined value of the tag-extender,
54
so that multiple clients may be installed.
56
The TIFFExtendProc method that you define should be used to override
57
the TIFF file's "vsetfield" and "vgetfield" methods, so that you
58
can trap your new, private tags, and install their values into
59
a private directory structure. For your convienience, a new pointer
60
has also been added to the "TIFF" file structure:
62
tidata_t tif_clientdir; /* client TIFF directory */
64
into which you may install whatever private directory structures you like.
65
You should also override the tag-printing method from within your
66
"vsetfield" method, to permit the symbolic printing of your new tags.
72
An example module has been provided as a template for installing
73
your own tags into a client tag extender. The module is called
74
"xtif_dir.c", and defines all of the interface routines, tag field
75
access, tag printing, etc. for most purpose.
77
To see how the client module operates, there are three "fake"
78
tags currently installed. If you use the existing makefile you can
81
make all -f Makefile.gcc !or Makefile.mpw
85
This will build two example programs called "maketif" and "listtif"
86
and then run them. These programs do nothing more than create a small
87
file called "newtif.tif", install the fake tags, and then list them out
88
using TIFFPrintDirectory().
90
Installing Private Tags
91
-----------------------
93
To use this module for installing your own tags, edit each of the files
99
and search for the string "XXX". At these locations the comments
100
will direct you how to install your own tag values, define their
101
types, etc. Three examples tags are currently installed, demonstrating
102
how to implement multi-valued tags, single-valued tags, and ASCII tags.
103
The examples are not valid, registered tags, so you must replace them with
106
To test the routines, also edit the test programs "maketif.c" and
107
"listtif.c" and replace the portions of the code that set the
108
private tag values and list them.
110
Once you have edited these files, you may build the client module
111
with the Makefile provided, and run the test programs.
113
To use these files in your own code, the "xtif_dir.c" module defines
114
replacement routines for the standard "TIFFOpen()" "TIFFFdOpen",
115
and "TIFFClose()" routines, called XTIFFOpen, XTIFFFdOpen and XTIFFClose.
116
You must use these routines in order to have the extended tag handlers
117
installed. Once installed, the standard TIFFGetField() and TIFFSetField
118
routines may be used as before.
120
Adding Extended Tags to "tools"
121
-------------------------------
122
To create an extended-tag savvy "tiffinfo" program or other utility, you may
123
simply recompile and link the tools to your "libxtiff" library, adding
125
-DTIFFOpen=XTIFFOpen -DTIFFClose=XTIFFClose -DTIFFFdOpen=XTIFFFdOpen
127
to the compile statement.
131
Send all reports and suggestions to ndr@tazboy.jpl.nasa.gov