MATLAB Answers

How to embed a TIFF image in an HTML file

7 views (last 30 days)
Krzysztof
Krzysztof on 14 Mar 2014

The following code embeds a TIFF image in a HTML page and opens that page in MATLAB browser. The image does not show up and the fall-through text does not show up either, although the type "image/tiff" is registered to be handled by AlternaTIFF v2.0.6 (at my place) and the page shows the image in Chrome no questions asked (I allowed AlternaTIFF wholesale). What am I doing wrong?

logo
print -dtiff logo
a_f = fopen ('logo.html', 'w');
a_f_c = onCleanup (@ () fclose (a_f));
close
fprintf...
    (a_f, ...
    [ '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" >', ...
    '<META HTTP-EQUIV=CONTENT-TYPE CONTENT="TEXT/HTML; CHARSET=ISO-8859-1" ><TITLE >Logo</TITLE >', ...
    '<P ><OBJECT HEIGHT=901 WIDTH=1201 TYPE="IMAGE/TIFF" DATA="logo.tif" ><PARAM NAME="TOOLBAR" VALUE="off" >No logo</OBJECT >', ...
    '<SCRIPT TYPE="APPLICATION/JAVASCRIPT" ><!-- ', 10, ...
    'var an_ix = 0, l_mt = navigator .mimeTypes, a_mt_c = l_mt .length; ', ...
    'for (; an_ix < a_mt_c; ++ an_ix)', ...
    '{ ', ...
    'var a_mt = l_mt [an_ix]; if (a_mt .type == "image/tiff") { var a_pl = a_mt .enabledPlugin; document .writeln ("<DL >"); ', ...
    'for (var a_prop in a_pl) document .writeln ("<DT >" + a_prop + "<DD >" + a_pl [a_prop]); document .writeln ("<\\/DL >"); }}', ...
    '//--></SCRIPT >' ]);
open logo.html

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!