The multimedia community often uses format names very casually: “Open this TIFF” or “I’m sending you an Ogg file” or “We have some old DICOM images – we should buy a viewer to see them”. While this is correct, because TIFF, Ogg, and DICOM are examples of file formats, it can be a bit unhelpful in understanding that there can be underlying complexities.
TIFF, DICOM, and Ogg are examples of containers, that is, they are wrappers that can contain one or more independent multimedia data components, such as images or audio streams that are each encoded into or compressed by their own image or audio format.  For instance, a TIFF file can hold a single JPEG-encoded image or it can contain multiple images encoded in the familiar JPEG format or another format such as JBIG.
Let’s revisit an earlier post (Ever Wonder What’s in Your Files?) to see a container in action. The sample Canon CR2 DNG-format file courtesy of holds a main image, a full-size thumbnail, a small thumbnail, and metadata. These two thumbnails and main image are all encoded in a lossless JPEG format. The metadata provides information about how, when, and where the picture was taken.
The DNG file also contains a second small thumbnail encoded in a packed format that is different from the JPEG encoding.
Containers work by having header and pointer or tag information to handle all of the bookkeeping for the data components it holds.
A container can have a header or other section that has information about the data enclosed. For example, a DICOM medical file may have patient information such as a name and birthdate, while a DNG camera file typically has information about each enclosed image just before the start of the image data.
The layout of a container is carefully specified. For instance, some containers have pointers to where specific data components are located in the file, that is, the offset in bytes from the start of the container:Other containers indicate components by “tags”, that is, reserved sequences of numbers or letters, perhaps with lengths of the associated data:
These different layouts make it easy for a container viewer to locate and extract individual components for decoding and playback.
The main advantage of a container is that it can package together a great deal of information in a specified manner, you don’t need to keep track of multiple files, like a main image and its thumbnail.  Further, the same DNG container format (which is built on a TIFF format) allows for adding open or proprietary information about the camera, image, or image encoding. This allows the DNG format to easily store as many different copies of the image, possibly at different sizes or with different pre-processing as desired, and also handle a wide range of encoding formats.
Since containers generally don’t put constraints on content types,  there are no guarantees that a given reader would be able to access any or all of data in a particular container and, further, often readers will only show you the information which they can decode and not inform you of other contained pieces of data.  The issue of storing data in proprietary encoding formats is particularly challenging for containers such as DICOM, where reading the enclosed medical data may be essential to providing quality service.  When downloading or purchasing a viewer it is important to confirm that it is designed to work with the data that you need to view or, at a minimum, informs you of data components that is can’t decode appropriately.
Stay tuned for our next blog posts in which we’ll investigate certain types of formats and their associated containers.