TECHNICAL FEATURES OF THE TIFF, PNG, GIF AND JPEG/SPIFF IMAGE FILE FORMATS Peter Dowdell 6th December 2001 http://www.stridebird.com INTRODUCTION Digital image files have developed from an application-specific realm to one where they are expected to be shareable across applications and platforms. This requirement for robust data interchange has led to the development of various universally agreed standards. In creating an image file format, two key issues that need to be addressed are file size and inclusion of associated information. File size is significant both to reduce storage requirements for a large number of images and to reduce bandwidth requirements for transmitting images. File size reduction is achieved by using a suitable compression routine and by controlling the depth of colour information stored per pixel. Associated information greatly improves the administration of a large set of images. Images on their own are very difficult to categorise as their identification generally demands human intervention. By storing fields such as author, creation date, description and category within the image file itself, processes for filing and indexing an image library become possible. In an information distribution system, such as proposed by the RDN, the categorisation of the library is the key to creating a workable, indexable system. Several formats have become well established and each have their particular features and short-comings in a digital distribution scheme. JPEG/SPIFF JPEG (Joint Photographic Experts Group) is a compression process for dealing with continuous-tone images such as found in real-life photography which was finalised during the early 1990s. JPEG compression is inherently lossy by nature. This means that image information is permanently lost upon conversion due to reduction processes which average and normalise the data. This makes the format unsuitable for storing original images. The JPEG compression process does not specify a file format, and needs a wrapper of some sort to make it a workable format. At first, the JFIF (JPEG File Interchange Format) format was released as a basic way to encapsulate a JPEG encoded data stream, and this format has become prevalent, particularly on the web where it is natively supported on all popular browsers but also in application such as digital photography and image scanning. However, JFIF is a very simple structure that does not allow for the storage of meaningful associated information. The necessity for a more flexible storage format for JPEG led to the development of the SPIFF format. SPIFF (Still Picture Interchange File Format) can store images using many different compression methods and colour space schemes. When using a JPEG compression, the SPIFF should be readable by a JPEG compliant reader, gracefully ignoring the extended features of the SPIFF file. The SPIFF internal layout contains a directory structure. Standard Entries are defined for this directory, such as creator, time stamp, gamma correction and much more, and the concept is extensible with application-specific tags allowed. GIF GIF (Graphics Interchange Format) was developed by CompuServe, as a simple format for storing graphical images. It was created with the web in mind, and is natively supported by all popular browsers. It is possibly the most prevalent of all in terms of numbers of files in existence. At its heart is the lossless LZW compression algorithm, and it is here that one of the shortcomings of the format is found. The algorithm is patented by the Unisys Corporation, and requires applications that implement the codec (compression / decompression algorithm) apply for a license. The original GIF87a header contained the minimal information necessary for displaying of the image, and did not include comments and associated information. The later GIF89a version extends the functionality and introduces control extensions for including associated image information and application-specific settings. Its maximum image size of 64k x 64k, whilst large enough for most present day applications, could be a drawback in a library system where larger images are conceivable. And its constraint of a palette of 256 RGB colours is also a drawback for storing more complex imagery such as photography, where JPEG is superior. GIF’s support for interlacing, whereby progressive display improves the user experience over low-bandwidth connections, and broad support for animation and looping on web browsers provides a simple way to add interest to a web page. In the long-term, the GIF format is likely to fall to the wayside because of the licensing issue. The PNG format has been developed to provide an alternative and uses a nonproprietary algorithm. PNG PNG (Portable Network Graphic) format has been developed to provide an alternative to the GIF, and whilst based upon a similar process it avoids the use of a proprietary compression algorithm. It is unofficially known as “PNG’s Not GIF”, in the tradition of recursive acronyms in the Open Source community responsible for its creation. It has been designed with a far greater range of functionality compared to GIF, for example it can support images to a massive 2G x 2G size, various colour spaces with up to 48-bit colour depth and support for alpha channels, built-in data integrity checks and a more sophisticated progressive display function using the Adam7 technique. Its drawback compared to GIF is that it does not support animation and looping because it allows only a single image to be stored in the file. There is development underway to produce the MNG (Multiple Image Network Graphic) to provide this in a non-proprietary format. TIFF (TIFF 6.0) TIFF (Tagged Interchange File Format), developed since 1986, is a widely-supported, highly versatile format for storing and sharing images. It is utilised in many fax applications and is widespread as a scanning output format. Its versatility makes it a great choice for use as a general purpose library and archiving format, but lack of native support for TIFF in web browsers makes it less suitable for use on the web, requiring the use of a plug-in or conversion to a web-friendly file type. TIFF will store multiple images within one file, and will support many compression methods (including JPEG) and colourspace schemes. Maximum file size is capped at 4Gb. The tagged structure of the file is very flexible, and allows great scope for adding all manor of custom information within the file. Its versatile nature can be problematic, with issues such as large strip sizes (a contiguous portion of the image) overflowing memory allocation, and byte ordering. However, these can all be avoided with good, robust programming practice and awareness of the pitfalls. SUMMARY The features of the formats discussed in this document are summarised in the following tables: COMPARISON OF MAIN FILE FEATURES Name Current version Common extensions Colour depth Colour space Compression Progressive display Maximum size (pixels) Animation SPIFF ISO/IEC 10918-3 .spf, .jpg Bi-tonal to 32bit RGB YcbCr - various types CMY & CMYK YCCK & photo YCCK CIE L*a*b JPEG Mod Huffman MR, MMR JBIG Yes, for JPEG 4G x 4G (tiled) 64K x 64K No GIF 89a .gif 24bit Palette RGB PNG 1.2 .png Bi-tonal to 48 bit Palette RGB SRGB ICC LZW LZ77 – deflate Yes, 8 row interlacing 64K x 64K Yes, Adam7 2G x 2G TIFF 6.0 .tif, .tiff Bi-tonal to 24 bit Palette RGB YCbCr CMYK CIE L*a*b Uncompressed ITU-T6 LZW JPEG Possible (JPEG, LZW) 232 - 1 Yes No No Ranked in increasing order of suitability Future proof : GIF SPIFF PNG TIFF Web usability : TIFF SPIFF PNG GIF Extensibility / programmability : GIF SPIFF PNG TIFF