[AlternaTIFF :: Technical documentation :: How to embed]

How to embed TIFF files in HTML documents

Some possible methods of embedding TIFF files in HTML documents are demonstrated below.

The examples assume you have a TIFF document accessible at the relative URL "tiffdocument.tif". To demonstrate how to pass parameters (when possible), we show how to tell AlternaTIFF to display a photo-negative of the image. The examples with a green background are the ones we consider to be the best choices.

You should also make sure your web server is configured to assign the MIME type "image/tiff" to your TIFF files. Most web servers will do this by default.

This document also includes a section on auto-installing into IE.

Example 1: <embed> only

The simplest and most reliable method is probably just to use the embed tag. However, embed is not a standard HTML element (prior to HTML 5).

Make sure to include width, height, and src attributes. The type attribute is optional but recommended.

HTML codeHow your browser handles it
<embed width=200 height=200
    src="tiffdocument.tif" type="image/tiff"
    negative=yes>

Example 2: Patent 5838906 workaround

Refer to Microsoft's documentation.

HTML codeHow your browser handles it
  <script src="embed.js"></script>

embed.js:
  document.write('<embed width=200 height=200 ' +
   'src="tiffdocument.tif" type="image/tiff" ' +
   'negative=yes>')

Example 3: Traditional <object> and <embed> combination

This may be the most popular way to embed plug-ins and ActiveX controls in web pages. It's bloated and nonstandard, but it works with almost any browser. Note that this will force Internet Explorer to use AlternaTIFF if it is installed, even if it isn't the default TIFF viewer.

HTML codeHow your browser handles it
<object width=200 height=200
  classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623">
 <param name="src" value="tiffdocument.tif">
 <param name="negative" value="yes">

  <embed width=200 height=200
    src="tiffdocument.tif" type="image/tiff"
    negative=yes>

</object>

Example 4: <object>: The valid-but-kind-of-a-hack way

You can try to cover all bases by putting the URL in both a "data" attribute and a "<param>" element. The result is syntactically valid, and seems to work well enough in current web browsers. But there may be subtle problems with it, and it may not work at all in older web browsers.

HTML codeHow your browser handles it
<object width=200 height=200 
  data="tiffdocument.tif" type="image/tiff">
 <param name="src" value="tiffdocument.tif">
 <param name="negative" value="yes">
</object>

Example 5: <object>: The IE-only way

The object element works best in IE when you include a classid attribute, which is the unique identifier of the control you want to use. This method will force your visitors to use AlternaTIFF, even if they have another TIFF viewer installed. It's unlikely to work in browsers other than IE.

HTML codeHow your browser handles it
<object width=200 height=200
  classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623">
 <param name="src" value="tiffdocument.tif">
 <param name="negative" value="yes">
</object>

Example 6: <object>: The official standard way

This method is not recommended, because too many browsers fail to follow the standard. As of this writing, it does not work in IE.

HTML codeHow your browser handles it
<object width=200 height=200 
  data="tiffdocument.tif" type="image/tiff">
 <param name="negative" value="yes">
</object>

Example 7: Frames

Using frames is easy, but it prevents you from passing parameters to AlternaTIFF, may make scripting more difficult or impossible, and can lead to other problems.

HTML codeHow your browser handles it
<iframe width=200 height=200
  src="tiffdocument.tif"></iframe>

Example 8: <img>

Some browsers support TIFF images in <img> tags, though they usually won't use a plug-in in this case.

HTML codeHow your browser handles it
<img width=200 height=200 
  src="tiffdocument.tif" alt="">


Auto-install for Internet Explorer

To create a page that allows Internet Explorer to auto-download and auto-install AlternaTIFF, get the latest CAB file from our archive, and put it on your web server. You'll need to use an embedding method that uses an <object> tag with a "classid" attribute. Add a "codebase" attribute similar to the following:
   <object classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623"
     codebase="alttiff.cab#version=1,5,0,1">
   </object>
Replace "alttiff.cab" with whatever you named the CAB file. The "version" tag should reflect the minimum version that is supported by your web site. If the visitor already has AlternaTIFF installed, IE will attempt to upgrade it if it is older than the version you specify. To translate an AlternaTIFF version number into the format used here, replace the periods with commas, and append ",1" to the end.