We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Using TIFF plug-in with files that have a different extension

montek asked
Medium Priority
Last Modified: 2013-12-25
I am trying to write a CGI application in C that queries a database (that part works) and returns a web page that refers to images (they are newspaper articles that have been scanned).

These images, however, have an .osm extension (that's the indexing extension required by the scanning/archiving software), but they are standard TIFF files.

I am using the TIFF plug-in by watermark and it seems to recognize .TIF files without a problem (of course), but cannot recognize this .OSMextension.

I have tried several things, including trying to mask the MIME type by returning "Content-type: image/tiff" and then using a binary spew of the contents of the file.  That returned garbage.  Then, I tried the Location parameter in front of that.  Similar problem.  I thought this could be as easy as convincing the web server that these
files were to be treated as TIFF files, but that hasn't worked (I even entered the new extension in the mime.typ file).  Right now, I am using the personal web server that comes with Front Page 98, but this will ported to IIS 3.0.
ANY help you can give me would be greatly appreciated
Watch Question

Most Valuable Expert 2014
Top Expert 2015

Can you make a link from file.osm to file.tif?


Just making a link does not invoke the Watermark TIFF plug-in.
Most Valuable Expert 2014
Top Expert 2015

Even if you access it from the .tif name?


If I change the CGI code and the filename to .tif, it works fine.  There are gigabytes of .osm files, though, and changing the names can not work in this case.

I would think changing the mime type in the server config would work, since the server should tell the browser the file is type image/tiff. When you do so, what headers does the server send? Try telnetting to localhost port 80 (or whereever your server is) and get a tiff file, e.g. type GET /whatever/whatever/filename.osm HTTP/1.0 (followed by Enter twice) and the server will fetch that file for you. Turn on telnet logging so you can go and see what the headers were. If the server's not saying it's image/tiff it may be the server's fault, if it is it's probably the plugin's fault.

Perhaps the plugin doesn't care about mime type, which would be very strange. I can't get that particular plugin, the link from the Netscape plugins page is broken, maybe you have an address for it?

If all else fails, I agree a data-dump script is the way to go, since you can call it with the filename and it will get filename.osm off your system and return it with the tiff header. I wrote such a script in perl and it worked beautifully: the browser recognized the script output as a tiff file, and either activated an external viewer or wrote it to disk (where I verified it was byte-for-byte identical to the original file). I think you should duplicate this test as a next step - if you can get access to perl it would be a little easier to test. Here's my very simple test script:

# Call as tiff.pl?filename
$file= '/path/'.$ENV{'QUERY_STRING'};
if (!open(TIFF, "<$file")) {
    print "Content-type: text/plain\n\nCan't open TIFF file: $file\n";
binmode TIFF;
binmode STDOUT;
print "Content-type: image/tiff\n\n";
$blocksize = 2048;
while (!eof(TIFF)) {
    read TIFF,$tiffdata,$blocksize;
    print $tiffdata;


Thanks, alamo.  I really appreciate the time you took to help me with this (you've even given me some new things to think about).  If you "answer" this question, I'll give you the points, because you deserve them.

Today, when I went to try it, everything worked.  You gotta love computers, huh?  Apparently, the MIME thing didn't kick in until today (I have no idea why).  Thanks again, everyone.

Thanks, montek, glad it worked out, that is by far the easiest solution. For future reference, the server only reads its configuration when it starts up, if you didn't know that maybe that's why the mime types didn't "take".
I would think changing the mime type in the server config would work, why don't you try testing it again?  :-)

(Read the comments for some things to help in debugging this, no point reposting them here).

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


It's funny, I did reboot the server, originally.  I don't know.  Sometimes things just work.  Anyway, thanks again!

(Ahh...computers...Gotta love 'em!)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.