AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home Imaging / TIFF / TIFF File Format FAQ
AWare Systems on-line

Home
Custom development
Imaging
    TIFF
        TIFF File Format FAQ
        BigTIFF Proposal
        TIFF Tag Reference
        TIFF Tag Viewer
        LibTiff Mailing List Archive
        TIFF in Delphi
        TIFF Links
    Custom development
TechTalks
Company
Links

Languages

  English version
  Nederlandse versie

Contact

Information: info@awaresystems.be
Helpdesk: support@awaresystems.be
Sales: sales@awaresystems.be



Valid HTML 4.01!



TIFF, Tag Image File Format, FAQ

Index

Question 1. What's in the name 'Tag Image File Format'? What makes TIFF different from other image file formats?
Question 2. As a user as well as a programmer, how do I convert a PNG image to TIFF? TIFF to PNG? Image in format X into format Y? How to crop/resize/do something else with the image?
Question 3. How about an informal introduction to the highest level TIFF structures?
Question 4. Where can I download the full TIFF specification?
Question 5. Is the TIFF specification being maintained and updated?
Question 6. Do I need a license from Adobe or anyone else to use TIFF?
Question 7. Can I not stream TIFF? Why does my library need seeking forward and backward in my TIFF file?
Question 8. What is the maximum size of a TIFF file?
Question 9a. So what are the defined tags exactly? Where can I find information on any specific tag?
Question 9b. How can I register my own private tags?
Question 10. When should I use what color space and compression scheme?
Question 11. What libraries support TIFF?
Question 12. Where can I find this LibTiff, and how do I use it in my program?
Question 13. Aren't you going to mention GeoTIFF?

Question 1. What's in the name 'Tag Image File Format'? What makes TIFF different from other image file formats?

Flexible tagsets

Many image file formats have an image header with fixed fields containing information such as image dimensions, color space specification, etc. The TIFF file format is different in that it allows for a flexible set of information fields. There exists a specification for many of these information fields, called 'tags', ranging from the most fundamental, like image dimensions, over the most luxurious like copyright information, up to so-called 'private tags' or 'custom tags' that you can define to hold your own application specific information. The TIFF specification defines a framework for an image header called 'IFD' (Image File Directory) that is essentially a flexible set of specifically those tags that the TIFF writer software wishes to specify.

The clear benefit of this scheme is that almost any information can accompany an image, while little information is absolutely needed, and image headers remain as lean as possible. There is little overhead, and enough flexibility to suit any need.

Flexible combination of colorspace, bitdepth/datatype, and compression scheme

Another major difference between most other image file formats and TIFF, is that TIFF allows for a wide range of different compression schemes and color spaces. These are specified in dedicated tags. Where other file formats are often designed to suit a single compression method, TIFF allows for JPEG or JBIG compression, the infamous LZW or the free-as-a-bird deflate compression, amongst many others. The same goes for color spaces. Theoretically, you could even use any compression method and color space of your own, though it goes without saying this would result in crippled portability.

Unless restricted by the nature of the chosen compression algorithm, any color space and any bitdepth can be combined with any compression scheme.

And the same goes for bitdepths and datatypes, too. One of the powerful TIFF features is support for a wide range of data types. You can store signed or unsigned integers, floating point values and even complex data in the TIFF file. Combined with the possibility to store an arbitrary number of image channels, this makes TIFF a very useful format to store scientific data.

Multi-page

One final important difference between TIFF and most other image file formats is that TIFF defines support for multiple images in a single file. Such a file is then called 'multi-page' TIFF. Thus, the TIFF format is very well suited to e.g. store the many pages of a single fax in a single file.

Drawbacks

Theoretically, all of this makes TIFF as flexible and suitable for a variety of applications as very advanced formats like PSD (Adobe's Photoshop® Document format). In fact, the clean simplicity as well as openness of the format is a major plus over a format like PSD. The TIFF format is owned by the same company that also owns PSD though, and as such, it is not very surprising that it has been more than a bit neglected over the last decade or so. That is probably the single most important drawback of TIFF: it lacks standardized support for advanced imaging features that were developed over the last couple of years. For instance, there is no standardized way to specify multi-layer relationships of different TIFF pages, even though a dedicated tag definition would be very feasible and very suitable. Neither is there a standarized tag for vector or text drawings.

One other drawback of TIFF, that it shares with the majority of other file formats, is its size limitation. The format uses 32bit offsets, and as such, it is limited to 4 gigabytes. (The BigTIFF file format is an ongoing attempt to design a next version of TIFF, specifically targeted at breaking the 4 gigabyte boundary.)

Photoshop is a registered trademark of Adobe Systems, Inc.

Question 2. As a user as well as a programmer, how do I convert a PNG image to TIFF? TIFF to PNG? Image in format X into format Y? How to crop/resize/do something else with the image?

There are a bunch of free and powerful tools around to accomplish simple as well as complex image processing tasks. Some of these are open source en can serve a programmer as a source of inspiration as well as documentation. The most widely used are:

ImageMagick
GraphicsMagick
NetPBM
VIPS

Question 3. How about an informal introduction to the highest level TIFF structures?

Sure. Here's the file header...

OffsetDatatypeValue
0WordByte order indication
2WordVersion number (always 42)
4Unsigned LongOffset to first IFD

The single member of this structure that is within the scope of this discussion is the third, the offset to the first IFD (Image File Directory). This IFD can be located anywhere in the file. Every 'page' in a multi-page TIFF is represented by exactly one IFD. Here's a more detailed view of this IFD...

OffsetDatatypeValue
0WordNumber of tags in IFD
2+x*12Tag structureTag data
2+(number of tags in IFD)*12Unsigned LongOffset to next IFD, if there is a next IFD
0 otherwise

The tags in this IFD should be sorted by code. Every tag takes up exactly 12 bytes, and looks like this...

OffsetDatatypeValue
0WordTag identifying code
2WordDatatype of tag data
4Unsigned LongNumber of values
8x * Tag data datatype
or Unsigned Long offset
see below
Tag data
or offset to tag data
see below

What has been described as 'datatype of the tag data' in the table above is the datatype of the elementary building block of this tag data. Thus, if the tag data is an array of bytes, this datatype would be byte. The tag data length, therefore, is the size of this datatype, multiplied by what has been described as 'number of values'. If this data length is smaller than or equal to 4 bytes, the actual tag data is included in the IFD, at offset 8 from the beginning of the tag structure. Otherwise, the tag data is stored in any other location within the TIFF file, and a pointer to that location, from the beginning of the file, is written at offset 8 from the beginning of the tag structure.

In other words, if the tag data is smaller than or equal to 4 bytes, it fits. Otherwise, it is stored elsewhere and pointed to.

That's it, that's all there is to the highest level TIFF structure. Except for one more thing: the TIFF specification explicitly forbids tag data to include any offsets into the file or into any other TIFF data block, except for the documented special cases (TileOffsets, StripOffsets,...). This enables total relocatability of all structures and data blocks. That is a major corner stone of the format. It means it is actually easy to, e.g. unlink an IFD or concatenate multiple single-page TIFF to a single multi-page TIFF, or vice versa. If any tag's data could contain offsets pointing anywhere in the file, then software doing this or otherwise relocating data blocks should be aware of the exact nature of every tag's data in order to find all data blocks, and know what pointers ought to be changed. That is unfeasible, on the one hand, due to the number of defined tags and, on the other hand, it inhibits extendability and private tags.

Instead, the specification says that all tag data needs to be 'self-contained', and that only a selected few special tags are allowed to point to other locations in the file. Thus, all blocks become freely relocatable, can be read and written out in any order, and any software can quite simply joggle around all this TIFF data, with only inbuilt knowledge of these highest level structures, and of the selected few special tags.

Question 4. Where can I download the full TIFF specification?

TIFF Specification, revision 6.0
TechNote2 on JPEG-in-TIFF
TIFF Specification Supplement 1
TIFF Specification Supplement 2

Some standards that build on top of TIFF are:

GeoTIFF Format Specification, Revision 1.0
RFC 2301 - File Format for Internet Fax
DNG, Digital Negative, standard for digital camera RAW files

Question 5. Is the TIFF specification being maintained and updated?

TIFF was developed by Aldus and Microsoft Corp, and the specification was owned by Aldus, which in turn merged with Adobe Systems, Incorporated. Consequently, Adobe Systems now holds the Copyright for the TIFF specification.

The last major update of the specification, revision 6.0, dates back 1992. (No, this page is not outdated.) Adobe added a supplement in 1995, which is still marked 'draft'. In 2002, Adobe absorbed a new-style JPEG-in-TIFF prepared externally in 1994 in a second supplement.

While there have been rumours of a new TIFF specification under development within Adobe over the years, it does not appear to have a high priority. Nor is there any public process for specification revision. It is unclear whether a new specification version will be released by Adobe or not.

Question 6. Do I need a license from Adobe or anyone else to use TIFF?

You don't need a license from Adobe to implement software reading and writing the TIFF format. You may need a license for use of existing TIFF libraries though libraries with minimal licensing requirements are also available.

At one time there was a need for an LZW license from Unisys to implement LZW compression support in TIFF, but it is our believe all patents have now expired.

Question 7. Can I not stream TIFF? Why does my library need seeking forward and backward in my TIFF file?

TIFF is not a streamable format. It is its very nature that all data blocks can be written in any order that is convenient for the particular application and/or TIFF encoding library. Even if a particular writer and particular reader implementation would agree on some sort of logical data block order, chances are that either or both need to access a certain block twice (e.g. delayed writing of offset to next IFD) and/or not need to access certain blocks at all (e.g. when a reader is not interested in the value of the Artist tag, or ignores SubIFDs). The possibility of reader and writer agreeing on a logical data block order seems even more remote when there are multiple pages or SubIFDs. And anyway, there is not just a single pair of writer and reader, instead there are plenty of different implementations. TIFF editing further obscures the issue as most implementations agree it implies appending at least those modifications that are longer than the original, rather than 'inserting' them, resulting in a file that no reader could hope to read sequentially.

There have been some attempts to build a more streamable 'sub-format' out of it, by defining such a 'logical' data block order, but none of these has been very succesful. If you need streaming, you probably need JPEG or PNG.

Question 8. What is the maximum size of a TIFF file?

The format uses 32bit offsets, and as such, it is limited to 4 gigabytes. Many implementations handle these offsets using signed integers, and thus support files of up to 2 gigabytes, but the only real limit resulting from the format specification is 4 gigabytes.

The BigTIFF file format is an ongoing attempt to design a next version of TIFF, specifically targeted at breaking the 4 gigabyte boundary.

Question 9a. So what are the defined tags exactly? Where can I find information on any specific tag?

The number one source on this is the TIFF specification. Note that this doesn't include any private tags or custom tags, of course. Also, please note that the JPEG-in-TIFF section is overridden by TechNote2, absorbed in TIFF Specification Supplement 2

Another, more informal source of tag information is the TIFF Tag Reference. It contains a list of basic properties as well as a short description and pointers to more information on every sufficiently known tag. Anyone interested in sharing information about any private tags is welcome to tell us about it, and we'll make sure to include it. The free TIFF Tag Viewer for Windows might also prove useful.

Finally, there is over ten years of TIFF and LibTiff mailing list activity that you may wish to consult. Especially note the 'local Google' archive search. If Google's technology applied to this vast resource doesn't yield any information, nothing will.

Question 9b. How can I register my own private tags?

TIFF tag and TIFF compression ID registration is handled by Adobe Developer Relations. This Adobe page contains more detailed instructions.

This registration process is not related to our own unofficial TIFF Tag Reference. If you register with Adobe to allocate your private tag codes, or have already done so in the past, we recommend submitting the necessary information to this Tag Directory next. There's no web-based registration scheme involved in this bit, a simple e-mail to info@awaresystems.be will do.

Question 10. When should I use what color space and compression scheme?

Due to the flexible combination of raster data with a vast amount of different compression schemes and color spaces, TIFF can be very suitable for a wide range of applications. Here is a sample of just the most popular or common applications.

ApplicationCompression scheme and color space
Bilevel dithered or very complex imagerycolorspace black and white
compression G3, G4, or perhaps JBIG
Bilevel artificial imagerycolorspace black and white
compression G3 or G4
Normal range grayscale or color photographic imageryIf compression is more important than quality
colorspace Grayscale or YCbCr(*)
compression JPEG(*)
If quality is more important than compression
colorspace Grayscale, RGB, or CIE L*a*b*
compression LZW or Deflate
If quality is of utmost importance
colorspace 16bit per channel or even floating point RGB, or 16bit per channel CIE L*a*b*
compression LZW or Deflate
Normal range Grayscale or color artificial imageryIf the number of colors <=256
colorspace Palette would be most suitable
compression LZW or Deflate
If the number of colors >256
colorspace Grayscale, RGB, or CIE L*a*b*
compression LZW or Deflate
Dynamic range Grayscale or color imagerycolorspace floating point Grayscale or RGB
compression LZW or Deflate

(*) The YCbCr color space and JPEG compression scheme are de facto related. Other than using JPEG as compression scheme, there is in our humble opinion no good reason for using YCbCr.

Question 11. What libraries support TIFF?

The number one TIFF library is LibTiff. It was originally conceived by Sam Leffler, and has more recently been maintained by Frank Warmerdam and Andrey Kiselev. It's free and open source, and is properly supported in the TIFF and LibTiff mailing list.

Little cms, a free color management engine by Marti Maria, includes a small utility 'tifficc' that links together LibTiff and the color management engine. It basically applies profile chains to TIFF files, and can also be used for such things as converting from RGB TIFF to CMYK TIFF, or working with other TIFF colorspaces like Lab, YCbCr,...

There are other TIFF implementations. Python Imaging Library contains a TIFF implementation in pure Python. There are many write-only implementations; it is relatively easy to make a program writing a particular TIFF flavor (that was one of the format design goals).

If your company has a commercial imaging product that supports TIFF properly, and you wish for a link in this section, drop us a line.

Question 12. Where can I find this LibTiff, and how do I use it in my program?

LibTiff, a free and open source TIFF codec
Using LibTiff
LibTiff reference

There is also a good tutorial available:

Graphics programming with LibTiff, part 1
Graphics programming with LibTiff, part 2

Question 13. Aren't you going to mention GeoTIFF?

Sure, we are! GeoTIFF represents an effort by over 160 different remote sensing, GIS, cartographic, and surveying related companies and organizations to establish a TIFF file format based interchange format for georeferenced raster imagery.